[英]CSS Z-Index not working on absolute positioning
I have the following situation: There are several div containers in my code. 我有以下情况:我的代码中有几个div容器。
.outside { position: relative; z-index: 1; } .options { position: absolute; z-index: 999; }
<div class="outside"> <div class="inside"> <div class="options">Content</div> </div> </div>
The Selection of three divs above is repeated several times. 上面的三个div的选择重复几次。 The problem i have now is that the outside div will overlap the options div.
我现在遇到的问题是外部div将与选项div重叠。 I tried to set this up with the z-index but it is not working.
我尝试使用z-index进行设置,但无法正常工作。 Does anyone have a solution for this?
有人对此有解决方案吗?
Move position:relative;
移动
position:relative;
and the z-index from .forum_post_outside
to .forum_arrow_outside
, also remove position: absolute;
以及从
.forum_post_outside
到.forum_arrow_outside
的z索引,也删除了position: absolute;
from .forum_arrow_outside
, also added float: right;
从
.forum_arrow_outside
,还添加了float: right;
to .forum_arrow_outside
: 到
.forum_arrow_outside
:
.forum_post_outside { border: none; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; min-height: 75px; padding: 0 5px; width: 100%; background-color: #333; margin-bottom: 2px; } .forum_arrow_outside { position: relative; z-index: 1; float: right; width: 150px; } .forum_arrow_top { position: absolute; top: 0; right: 0; } .forum_arrow_inside { max-width: 110px; -moz-box-shadow: 5px 5px 10px 0px rgba(0, 0, 0, 0.5); -webkit-box-shadow: 5px 5px 10px 0px rgba(0, 0, 0, 0.5); box-shadow: 5px 5px 10px 0px rgba(0, 0, 0, 0.5); background-color: #eee; padding: 10px; border: 1px solid #ccc; -moz-border-radius: 2px; -webkit-border-radius: 2px; -khtml-border-radius: 2px; border-radius: 2px; z-index: 999; position: absolute; top: 0; left: 0; } .forum_drop_down { margin: 0!important; margin-top: 10px!important; line-height: 20px; min-width: 110px; border-bottom: 1px solid #ccc; color: #000; }
<div class="forum_post_outside"> <div class="forum_arrow_outside"> <div class="forum_arrow_inside"> <div class="forum_drop_down"> <img src="/images/delete_16.png">Delete</div> <div class="forum_drop_down"> <img src="/images/unpin-16.png">Unpin</div> <div class="forum_drop_down"> <img src="/images/edit_16.png">Edit</div> </div> </div> </div> <div class="forum_post_outside"> </div> <div class="forum_post_outside"> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.