简体   繁体   English

元素中的不透明度和z索引

[英]Opacity and z-index in elements

I have a site with a dropdown menu. 我有一个带下拉菜单的网站。 When the menu expands it goes behind some li that i have later on. 当菜单展开时,它会出现在后面的li后面。 The z-index on the li is 10 and currently the dropdown ul does not have a z-index but it has opacity:1 . li上的z-index是10,当前下拉列表ul没有z索引,但是具有opacity:1 Tried every combination of opacities and z-indexes in the mentioned elements but i cannot make it work as expected. 在提到的元素中尝试了不透明度和z索引的每种组合,但我无法使其按预期方式工作。 I want the li to be behind the dropdown ul when it expands. 我希望li在展开时位于下拉列表ul的后面。 The li is relatively positioned (my design needs that) and has a float property. li相对定位(我的设计需要这样做)并具有float属性。 The only way i can make this work is by using z-index:1 for the li but i don't want that as it messes up with some other elements. 我可以做这项工作的唯一方法是对li使用z-index:1 ,但是我不希望这样,因为它与其他一些元素弄混了。 Any ideas? 有任何想法吗?

If you want to use the z-index property, we must put on the div position:absolute; 如果要使用z-index属性,则必须放在div position:absolute; , position:fixed; position:fixed; or position:relative; position:relative;

You should maybe take a look at your positions tags, 您也许应该看看自己的职位标签,

If you don't give position value to your elements in your css, then your z-index value will not be considered by the browser. 如果您没有在CSS中为元素提供位置值,那么浏览器将不会考虑您的z-index值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM