我做了一个css hoverable菜单。问题是菜单内容(下拉内容)显示在菜单下方的正下方。我如何让内容显示在“井”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;
}
WELL
<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>
答案 0 :(得分:1)
您需要为.dropdown-content css添加z-index属性。
.dropdown-content{
... other styles ...
z-index: 2;
}