[英]CSS z-index not working when animating a div with jquery?
Can anyone help me make the red div roll OVER the blue paragraph? 谁能帮助我让红色div覆盖蓝色段落?
http://jsfiddle.net/B3rQR/1/ http://jsfiddle.net/B3rQR/1/
I tried doing it with z-index, but couldn't make it work: 我尝试使用z-index进行此操作,但无法使其正常工作:
div {
z-index: 1;
}
p {
background-color: blue;
z-index: 0;
}
Sorry if this is a noob question. 抱歉,这是一个菜鸟问题。
Thanks in advance! 提前致谢!
Sure, just add position:relative;
当然,只需添加
position:relative;
to your div's rules. 按照您的div的规则。
z-index
only works on positioned elements. z-index
仅适用于定位的元素。
You can position the <ul>
or the <div>
- eg 您可以
<ul>
或<div>
-例如
ul {
background-color: yellow;
width: 100%;
height: 50px;
z-index: 1; /* z-index doesn't work on statically positioned elements */
position: relative;
}
add position: relative;
添加
position: relative;
in div 在div
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.