Although I've seen similar posts, I'm struggling to understand why my function isn't working. I'm still learning, so please be gentle with me! Here's the code snippets:
HTML:
<div id="BurgerMenu">
<button onclick="menuBurger()">
☰
</button>
</div>
<nav id="SecondNav">
<ul>
<li><a href="#itineraires">Itinéraires</a></li>
<li><a href="#trafic">Infos trafic</a></li>
<li><a href="#actualite">Actualité</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
CSS:
@media screen and (max-width: 812px) {
#FirstNav{
display:none !important;
}
#sectionLogo{
margin: 25px;
}
#secondHeader{
display :flex;
flex-flow: row-reverse nowrap !important;
justify-content: space-between;
align-items: baseline !important;
padding-left: 40px;
padding-right: 40px;
}
#BurgerMenu{
display: block !important;
}
#SecondNav{
display: none !important;
}
}
JavaScript Function:
function menuBurger(){
var x = document.getElementById("SecondNav");
if (x.style.display === "none"){
x.style.display = "block";
} else {
x.style.display = "none";
}
}
I'm unable to remove the !important in CSS as it is necessary for the functionality. Thank you for your explanation!