I have created a mobile and tablet version for my navbar(which gets activated when you click on the hamburger) and on the desktop resolution, I want the navbar to be visible immediately. And I have done so far... but the navbar links are not clickable on the desktop version. The reason for that is because on the HTML part I added onClick action on the hamburger for the menu but on the desktop resolution I just make display: none for the hamburger menu so the user never actually activates the hamburger for the navbar links to become clickable.
So this is the HTML code:
<ul id="menu">
<li ><a href="/index.html" >Home Page</a></li>
<li ><a href="/content.html" >Content</a></li>
<li ><a href="/store.html" >Products</a></li>
<li ><a href="/contact.html" >Contact</a></li>
</ul>
<input type="checkbox" id="check">
<div onclick="myFunction(this)">
<div ></div>
<div ></div>
<div ></div>
</div>
This is the CSS code:
#check {
display: none;
}
#menu{
background-color: white;
margin: 60px 0 0 0;
padding: 0;
display: block;
position: fixed;
font-size: 1.6rem;
justify-content: space-around;
font-weight: normal;
height: 100vh;
width: 100%;
align-items: center;
text-decoration: none;
list-style:none;
opacity: 0;
transition: 0.5s;
pointer-events: none;
}
#menu li{
text-align: center;
margin: 40px 0;
}
#menu.active{
pointer-events: auto;
opacity: 100;
}
And this is what I did for the desktop resolution:
@media only screen and (min-width: 1000px) {
#menu{
padding: 0;
margin: 0;
display: flex;
position: fixed;
justify-content: space-between;
font-weight: normal;
height: 100px;
width: 40%;
align-items: center;
right: 100px;
text-decoration: none;
list-style:none;
opacity: 100%;
}
#menu li{
font-size: 1.2rem;
text-align: center;
z-index:9999999;
}
I don't know how to fix this without breaking my code for mobile and tablet resolutions.
CodePudding user response:
Remove the Pointer events or comment it
#menu{
background-color: white;
margin: 60px 0 0 0;
padding: 0;
display: block;
position: fixed;
font-size: 1.6rem;
justify-content: space-around;
font-weight: normal;
height: 100vh;
width: 100%;
align-items: center;
text-decoration: none;
list-style:none;
opacity: 0;
transition: 0.5s;
/*pointer-events: none;*/
}
CodePudding user response:
Use 'onclick' instead of 'onClick'.
You should use this because Javascript is case sensetive.