frre tyy frre tyy - 2 months ago 13
CSS Question

Css Hover menu displaying behind div

I made a css hoverable menu.The problem is the content of the menu(dropdown-content) displays behind the well below the menu.How do i make the content show infront of the "well" div class.thank you.

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>



Answer

You need to add a z-index attribute to the .dropdown-content css.

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