1
I don’t know the script art, and I’m creating a page with a responsive menu. I’ve done a lot of research and I’m testing a way, so far it’s not working.
I created the following code html
:
<div class="header" id="menu-header">
<nav class="menu-header">
<ul>
<li><a href="#funcionalidades">Funcionalidades</a></li>
<li><a href="#">FAQ</a></li>
<li><a href="#precos">Preço</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Contato</a></li>
</ul>
<a class="toggle-nav" href="#menu-header-resp">☰</a>
</nav>
</div>
<div id="menu-header-resp">
<nav>
<ul>
<li>teste</li>
<li>teste 2</li>
</ul>
</nav>
</div>
With this html
, also created the following commands css
:
.toggle-nav {
display:none;
}
div#menu-header-resp {
display: none;
}
div#menu-header-resp:target {
display: block;
}
@media screen and (max-width:1000px) {
nav.menu-header ul {
display: none;
}
.toggle-nav {
display: block;
color: rgba(255,255,255,.55);
font-weight: 700;
font-size: 21px;
}
.toggle-nav:hover {
color: rgba(255,255,255,.75);
transition: .2s;
}
}
I came to this code stage after studying a lot about the function target
.
In short, my intention is that the div id="menu-header-resp"
is not displayed unless called by clicking a class="toggle-nav"
.
I had the idea to create these codes after reading one of the answers to this question: Click on an image to show a div
Mark with Target you will not be able to show and then "demostrar", once you click on
a class="toggle-nav"
You can’t take the:target
and the menu will be visible forever... that’s exactly what you want, or you want to show with one click and hide another?– hugocsl
I don’t need to hide, just display with a click
– user99005
Young just to give you the feedback your jsfiddle.net/sof8renr/5 works fine, if you remove the Script you made... it is "bugging" the menu for some reason. If you remove the Script everything works normal
– hugocsl