[英]spin.js top option does not work
I try to use the spin.js 我尝试使用spin.js
I want it to pop up in the middle of the div element. 我希望它在div元素的中间弹出。 So I did set: 所以我设置了:
position: 'relative' top:'50%' left:'50%' 位置:“相对”顶部:“ 50%”左侧:“ 50%”
but the top option doesn't work. 但是top选项不起作用。 After analyzing the problem I could break it down to a html/css problem: 分析问题后,我可以将其分解为html / css问题:
<div style="background-color: red">
<div style="position:relative; height:20px; width:20px; top:50%; left:50%; background-color:blue"></div>
1st div line<br>br line<br>br line 2
<div>div line 1</div>
<div>div line 2</div>
</div>
In this example the blue element should be in the middle of the red, but it isn't. 在此示例中,蓝色元素应位于红色的中间,但不是。 and here is the fillde for it: 这是它的填充:
http://jsfiddle.net/exu77/obcg3cxv/ http://jsfiddle.net/exu77/obcg3cxv/
This is the plunker to the original version with spin.js 这是spin.js原始版本的首创
http://plnkr.co/edit/qwjArDtnqGZQgbkQiRYt?p=preview http://plnkr.co/edit/qwjArDtnqGZQgbkQiRYt?p=preview
I was able to get it to work by adding a height to the jsSpinner div. 我可以通过在jsSpinner div中增加高度来使其工作。
<div id="jsSpinner" style="background-color:red; height: 100px;">spin in the red part
<br>br line
<br>br line 2
<div>div line</div>
<div>div line 2 </div>
As for why this works? 至于为什么这样? That part I don't know. 那部分我不知道。
The position:relative
must be applied to the parent element, ie the div that contains the spinner. 必须将position:relative
应用于父元素,即包含微调框的div。 The spinner itself needs position:absolute
(which is the default). 微调框本身需要position:absolute
(默认设置)。 Here is is an updated version of your plunker where the spinner is centered inside the red box: http://plnkr.co/edit/GstXJdzyDtBIyMLuzbcY?p=preview 这是微调器的更新版本,微调器位于红色框内: http ://plnkr.co/edit/GstXJdzyDtBIyMLuzbcY?p=preview
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.