gpt4 book ai didi

css - Z-指数 |我的网站需要帮助

转载 作者:行者123 更新时间:2023-11-28 10:50:57 26 4
gpt4 key购买 nike

我对 CSS 中的 z-index 有疑问。

代码:

div.banniere{
background-image:url('../img/banniere.png');
background-repeat: no-repeat;
background-position: -23px 0;
height: 750px;
width: 100%;
position: absolute;
z-index: -1;
}

p.menu-king{
color: white;
transform: rotate(270deg);
width: 250px;
height: 75px;
padding-bottom: 100px;
margin-bottom: 75px;
z-index: 1;
}

div.menu-bar{
background: black;
top: 0;
position: fixed;
height: 100%;
width: 70px;
list-style: none;
z-index: -2;
margin-top: 100px;
}


div.menu-bar > ul{
text-decoration: none;
list-style: none;
font-size: 24px;
position: absolute;
z-index: 1;
}

li.menu{
font-size: 40px;
height: 64px;
}

li.menu > span{
visibility: hidden;
}

li.menu:hover > span{
visibility: visible;
}

li.menu:hover > span > a{
background: black;
padding-left: 50px;
padding-right: 20px;
text-decoration: none;
color: #ffffff;
transition: all 0.7s ease-out;
display:inline;
}


img.menu-icon{
position: absolute;
left: 5px;
margin-bottom: 70px;
z-index: 1;
}


<div class="banniere"></div>
<div class="menu-bar">
<p class="menu-king">The king's offical website</p>
<ul>
<li class="menu"><img src="../img/1a.png" alt="home" class="menu-icon" /><span><a href="index.php?page=index">Accueil</a></span></li>
<li class="menu"><img src="../img/2b.png" alt="home" class="menu-icon" /><span><a href="index.php?page=new">Actualité</a></span></li>
<li class="menu"><img src="../img/2b.png" alt="home" class="menu-icon" /><span><a href="index.php?page=wof">WoF</a></span></li>
<li class="menu"><img src="../img/2b.png" alt="home" class="menu-icon" /><span><a href="index.php?page=post-tester">POST-tester</a></span></li>
<li class="menu"><img src="../img/2b.png" alt="home" class="menu-icon" /><span><a href="index.php?page=contact">Contact</a></span></li>
</ul>
</div>
<div class="contenu">

我要:

  • div.banniere -> 在 Z 中的位置:-1
  • div.menu-bar -> 在 Z 中的位置:-2
  • div.menu-bar > ALL -> Z 中的位置:1

但在我的代码中它不起作用...为什么?

感谢您的支持!

最好的问候,Bonvin Maxime。

最佳答案

很大程度上取决于您的 html 代码。但是,如果您对容器项进行 z-index 和定位就足够了,您不需要将 z-index 和位置添加到容器的所有子元素。我还看到您已经将 z-index 添加到 p.menu-king,但是那个错过了 position 属性。没有设置位置,z-index 无效。我建议您只将 z-index 添加到容器中,并清理您的代码。

关于css - Z-指数 |我的网站需要帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22792824/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com