gpt4 book ai didi

html - Css 悬停菜单显示在 div 后面

转载 作者:太空宇宙 更新时间:2023-11-04 09:44:38 25 4
gpt4 key购买 nike

我制作了一个 css 悬停菜单。问题是菜单的内容(下拉内容)显示在菜单下方的井后面。如何让内容显示在“井”div 类的前面。谢谢。

HTML

  <div class = "dropdown">
<button class = "dropbtn">
<b>HOME</b></button>
<div class ="dropdown-content">
<a href ="#">About Us</a>
<a href ="#">What we Do</a>
<a href ="#">Services</a>
<a href ="#">Leadership</a>
</div>
</div>
<div class = "dropdown">
<button class = "dropbtn">
<b>WHO WE ARE</b></button>
<div class ="dropdown-content">
<a href ="#">C#</a>
<a href ="#">Javascript</a>
<a href ="#">HTML</a>
<a href ="#">Python</a>
</div>
</div>

<div class = "dropdown">
<button class = "dropbtn">
<b>CCTP</b></button>
<div class ="dropdown-content">
<a href ="#">Brian M</a>
<a href ="#">Qata S</a>
<a href ="#">Nyonyozi J</a>
<a href ="#">Frank K</a>
</div>
</div>

CSS

.dropbtn{
background-color: #2c3e50;
color:white;
padding: 16px;
font-size: 13px;
font-family: arial;
border:none;
cursor:pointer;
border-radius: 7px;
border:3px solid #D67C1C;
height: 43px;

}
/*container needed to position the dropdown content*/
.dropdown{
position: relative;
display:inline-block;
background-color: #2c3e50;
}
/*Dropdown content(hidden by default)*/
.dropdown-content{

display: none;
border-radius: 7px;
font-weight: 400;
font-style: bold;
position: absolute;
background-color: #2c3e50;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}
/* Links inside the dropdown */
.dropdown-content a{
color: white;
padding:12px 16px;
text-decoration: none;
display: block;

}
/*Change color of links on hover*/
.dropdown-content a:hover{
background-color: #D67C1C;
}
/*show the dropdown menu on hover*/
.dropdown:hover
.dropdown-content{
display: block;
}
/*change the background colorof dropdown-button when dropdown content is shown*/
.dropdown:hover
.dropbtn{
background-color: #D67C1C;

}

很好

<div class = "well">
<div class = "panel-body">

<h4>Welcome to Mobile Ltd</h4>
<p>Lorem ipsum dolaor sit amet,consecteur adisping elit.morbi gravida quam ante rutrum,in mollis ligula mattis.Integer mulla nissi,ellamcorper et posuere.Lorem ipsum dolaor sit amet,consecteur adisping elit.morbi gravida quam ante rutrum,in mollis ligula mattis.Integer mulla nissi,ellamcorper et posuere.Lorem ipsum dolaor sit amet,consecteur adisping elit.morbi gravida quam ante rutrum,in mollis ligula mattis.Integer mulla nissi,ellamcorper et posuere.Lorem ipsum dolaor sit amet,consecteur adisping elit.morbi gravida quam ante rutrum,in mollis ligula mattis.Integer mulla nissi,ellamcorper et posuere.Lorem ipsum dolaor sit amet,consecteur adisping elit.morbi gravida quam ante rutrum,in mollis ligula mattis.Integer mulla nissi,ellamcorper et posuere.Lorem ipsum dolaor sit amet,consecteur adisping elit.morbi gravida quam ante rutrum,in mollis ligula mattis.Integer mulla nissi,ellamcorper et posuere</p>
</div>

最佳答案

您需要将 z-index 属性添加到 .dropdown-content CSS。

.dropdown-content{
... other styles ...
z-index: 2;
}

关于html - Css 悬停菜单显示在 div 后面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39583668/

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