Objective
I aim to change the background color and restrict scrolling when a dropdown is opened. It should have a distinct color from the header, disabling scrolling until the dropdown is closed.
Challenges Faced and Solution Attempted
To prevent scrolling, I used $('body').toggleClass('hidden');
. However, setting a different background color has been difficult. As a workaround, I added an empty div with the class backdrop and styled it with a semi-transparent background color.
Code snippet provided below:
$(document).ready(function() {
$('.toggle').click(function() {
$('.toggle').toggleClass('active');
$('.toggle-content').toggleClass('active');
$('body').toggleClass('hidden');
});
});
: .hidden {
overflow: hidden;
}
.container {
width: 100%;
height: 1000px;
margin: 0 auto;
background-color: #eee;
}...
<!-- Remaining code not included for brevity -->