Is there a way to create a dropdown menu that changes the background window to transparent when hovered over?
Here is an example of what I am looking for:
https://i.sstatic.net/FplLm.png
The dropdown menu should look like this when hovered over:
https://i.sstatic.net/IoHI9.png
I would like the background window to become transparent when hovering over the dropdown menu, similar to a backdrop modal.
$(document).ready(function(){
$(".dropdown").hover(function(){
$(".backdrop").show();
}, function(){
$(".backdrop").hide();
});
});
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
}
.dropdown {
position: relative;
display: inline-block;
z-index: 101;
}
.dropdown-content {
display: none;
position: absolute;
right: 0;
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: #3e8e41;
}
.backdrop {
background-color:rgba(0,0,0,0.5);
opacity: 0.5;
height: 100%;
left: 0;
position: fixed;
top: 0;
width: 100%;
z-index:100;
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<div class="dropdown" style="float:left;">
<button class="dropbtn">Left</button>
<div class="dropdown-content" style="left:0;">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</div>
<div class="backdrop"></div>