SoulRider SoulRider - 5 months ago 27
CSS Question

How to make dropdown in html overlap another div

So I got a navigation bar and some of the items there are having a dropdown menu when you hover over them. Right below the nav bar, there is a slideshow of images. The problem is that everytime I hover on the dropdowns, The slideshow div gets in the way so the dropdown menu cant be seen.
enter image description here

i have the ff html code

<div class="dropdown">
<li class="dropbtn">About Us</li>
<div class="dropdown-content">
<a href="#"> Overview and History</a>
<a href="#">Vision</a>
<a href="#">Objectives</a>
<a href="#">Organization</a>
<a href="#">About NEU</a>

and the css

.dropbtn {
background-color: inherit;
color: black;
padding: 12px;
font-size: 20px;
border: none;
cursor: pointer;

.dropdown {
position: relative;
display: inline-block;
margin: 0;
padding: 0px;

.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);

.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;

.dropdown-content a:hover {background-color: #f1f1f1}

.dropdown:hover .dropdown-content {
display: block;

.dropdown:hover .dropbtn {
background-color: #0099ff;


You can use z-index attribute as it specifies the stack order of an element.

An element with greater stack order is always in front of an element with a lower stack order.

Note: z-index only works on positioned elements (position:absolute, position:relative, or position:fixed).


<!DOCTYPE html>
img {
    position: absolute;
    left: 0px;
    top: 0px;
    z-index: -1;

<h1>This is a heading</h1>

<img src="w3css.gif" width="100" height="140">

<p>Because the image has a z-index of -1, it will be placed behind the text.</p>


For more information : Check out here