5
I have the following code with a menu like Menu Accordion:
function marca() {}
body {font-family: Trebuchet MS;margin: 0px;}
nav {width: 100%;}
p {font-size: 14px;text-align: justify;}
.item label {font-size: 14px;color: #333;height: 20px;display: block;padding: 5px;background: #b8cce4;cursor: pointer;-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;}
.item ul {margin: 0px;padding: 0px;list-style: none;overflow: hidden;max-height: 0;background: #fefefe;-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;}
.item ul li a {padding-left: 1rem;font-size: 14px;color: #333;background: #fff;text-decoration: none;}
.item label:hover, .item ul li a:hover {text-decoration: underline;}
.item input {display: none;}
.item input:checked ~ ul {height: auto;max-height: 100%;}
.item label:before {content: "\002B";color: #444;font-weight: bold;float: left;margin-right: 5px;}
.item input:checked + label:before {content: "\2212";}
<nav>
<div class="item">
<input type="checkbox" name="nome" id="check1" onclick="marca();" />
<label for="check1">Categoria 1</label>
<ul>
<li><a href="#">Tabela 1</a></li>
<li><a href="#">Tabela 2</a></li>
</ul>
</div>
<br>
<div class="item">
<input type="checkbox" name="nome" id="check2" onclick="marca();" />
<label for="check2">Categoria 2</label>
<ul>
<li><a href="#">Tabela 3</a></li>
<li><a href="#">Tabela 4 </a></li>
</ul>
</div>
<br>
<div class="item">
<input type="checkbox" name="nome" id="check3" onclick="marca();" />
<label for="check3">Categoria 3</label>
<ul>
<li><a href="#">Tabela 5 </a></li>
<li><a href="#">Tabela 6 </a></li>
</ul>
</div>
<br>
<div class="item">
<input type="checkbox" name="nome" id="check4" onclick="marca();" />
<label for="check4">Categoria 4</label>
<ul>
<li><a href="#">Tabela 7</a></li>
<li><a href="#">Tabela 8</a></li>
</ul>
</div>
</nav>
What I’d like to do is this:
When the user clicks on a menu he opens the menu and the others remain closed. If I open another menu he must close the others!
I liked the css, had the knack. : ) +1 good question
– Marconi
@Marconi Really, it’s interesting to solve this by changing only CSS.
– Mathiasfc
Thank you aee =)
– Andrei