1
I made the following menu on css and opening/closing is working normal, but when I click on some item of the submenu, the menu closes before redirecting.
Would have some way around that problem?
#menu {
position: relative;
float: left;
display: inline-block;
margin: 10px 100px;
}
.item {
font-family: 'Open Sans', sans-serif;
position: relative;
display: inline-block;
font-size: 12.5px;
color: #969696;
margin-left: 30px;
cursor: pointer;
}
.open-button {
display: block;
width: 100%;
background-image: url(../../img/select-arrow-down.png);
background-repeat: no-repeat;
background-position: top right;
padding-right: 20px;
}
.open-button:focus {
pointer-events: none;
}
.open-button:focus + ul {
display: block;
}
ul {
position: absolute;
display: none;
top: 40px;
right: -20px;
width: 200px;
z-index: 10;
border-radius: 5px;
box-shadow: 0px 4px 6px #ccc;
background-color: #fafafa;
}
li {
position: relative;
float: left;
display: inline-block;
width: 100%;
}
a {
position: relative;
float: left;
display: inline-block;
width: 100%;
height: 36px;
line-height: 36px;
padding: 0 25px;
}
a:hover {
background-color: #f0f0f0;
text-decoration: none;
}
<nav id="menu">
<div class="item">
<span class="open-button" tabindex="0">Menu</span>
<ul>
<li>
<a href="{{ route('cliente-conta') }}">Meus dados</a>
</li>
<li>
<a href="{{ route('pedidos') }}">Meus pedidos</a>
</li>
<li>
<a href="{{ route('cliente-logout') }}">Sair</a>
</li>
</ul>
</div>
</nav>
Have you tried using
preventDefault()
orsetTimeout()
?– hugocsl
I don’t want to use any JS for this, I wanted to leave this menu 100% CSS
– Diego Vieira
I made a template for you to see in my reply only with CSS, but I had instead of a
span
I used ainput checkbox
, and instead of:focus
used:checked
– hugocsl