I have a navbar with a tiny topbar above it. This topbar has a dropdown button with a dropdown menu. How can I make this dropdown show on top of the navbar? I cannot change position:fixed;
on the navbar or topbar because these two have been aligned.
Changing the z-index:x;
property on either of those <div>
items has no effect and making one elements z-index:x!important;
does nothing either. What can I do?
.topbar {
margin: 0;
padding: 0;
position: fixed;
z-index: 1!important;
width: 100%;
height: 32px;
background-color: rgba(0,0,0,0.75);
}
.navbar {
margin-top: 32px;
width: 100%;
height: 65px;
position: fixed;
z-index: 3!important;
background-color: rgba(255,255,255,0.75);
border-top: 2px solid rgba(55,175,75,1.00);
border-bottom: 5px solid rgba(55,175,75,1.00);
box-shadow: 0 5px 10px rgba(0,0,0,0.4);
}
.dropdown {
position: absolute;
right: 0px;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 2!important;
height: 200px;
}
<div class="topbar" align="center">
<p>Topbar content and buttons</p>
<div class="dropdown" align="center">Dropdown content</div>
</div>
<div class="navbar" align="center">Navbar content and buttons</div>
Solved
This problem is solved by placing the <div class="topbar"></div>
and the <div class="navbar"></div>
inside a <div></div>
with property position:fixed;
and deleting the fixed position in the topbar and navbar.