I've designed a vertical navigation accordion menu that allows users to hover and click on any title (label) to expand a sub-menu.
However, I'm facing an issue where my drop-down arrow is not clickable, unlike the rest of the label which works fine.
How can I make my "arrow" clickable so it functions just like the rest of the label?
CSS:
/*Global*/
html,
body {
width: 100%;
margin: 0;
padding: 0;
font-family: helvetica;
}
/*Functionalty*/
.multi-level,
.item ul,
.nav input[type="checkbox"] {
display: none;
}
#menu:checked~.multi-level,
.item input:checked~ul {
display: block;
}
/*Arrow*/
.arrow {
width: 10px;
height: 10px;
vertical-align: middle;
float: left;
margin: 9px 0.5em 0 2em;
}
.item input+.arrow {
transform: rotate(-90deg);
transition: 0.1s;
}
.item input:checked+.arrow {
transform: rotate(0deg);
transition: 0.1s;
}
img {
z-index: 1;
position: relative;
}
/*Styles*/
label:hover {
cursor: pointer;
background-color: #f2f2f2;
position: relative;
}
li:hover {
background-color: #f2f2f2;
}
label {
width: 100%;
display: block;
}
.nav {
width: 100%;
background-color: white;
overflow-x: hidden;
/*border-bottom: 1px solid #CFD8DC;*/
}
/*#nav-icon {
font-size: 28px;
line-height: 50px;
padding-left: 1em;
color: white;
background-color: #F44336;
}*/
.nav ul,
.nav li,
label {
line-height: 30px;
margin: 0;
padding: 0 2em;
list-style: none;
text-decoration: none;
color: #000;
font-weight: 100;
width: 100%;
}
.item ul {
padding: 0 0.25em;
}
.nav li a {
line-height: 30px;
margin: 0;
padding: 0 2em;
list-style: none;
text-decoration: none;
color: #000;
font-weight: 100;
}
.item {
margin: 0 0 0 -1.5em;
}
.sub-item {
padding: 0 0m;
}
HTML:
<div class="nav">
<input type="checkbox" id="menu" checked />
<label for="menu"></label>
<div class="multi-level">
<div class="item">
<input type="checkbox" id="A" />
<img src="https://png.icons8.com/material/50/000000/expand-arrow.png" class="arrow"><label for="A">Category One</label>
<ul>
<li><a href="#">Sub-Category One</a></li>
<li><a href="#">Sub-Category Two</a></li>
<li><a href="#">Sub-Category Three</a></li>
</ul>
</div>
<div class="item">
<input type="checkbox" id="B" />
<img src="https://png.icons8.com/material/50/000000/expand-arrow.png" class="arrow"><label for="B">Category Two</label>
<ul>
<li><a href="#">Sub-Category One</a></li>
<li>
<div class="sub-item">
<input type="checkbox" id="B-A" />
<img src="https://png.icons8.com/material/50/000000/expand-arrow.png" class="arrow"><label for="B-A">Sub-Category Two</label>
<ul>
<li><a href="#">Sub-Sub-Category-1</a></li>
<li><a href="#">Sub-Sub-Category-2</a></li>
<li><a href="#">Sub-Sub-Category-3</a></li>
<li><a href="#">Sub-Sub-Category-4</a></li>
<li><a href="#">Sub-Sub-Category-5</a></li>
<li><a href="#">Sub-Sub-Category-6</a></li>
</ul>
</div>
</li>
</ul>
</div>
<div class="item">
<input type="checkbox" id="C" />
<img src="https://png.icons8.com/material/50/000000/expand-arrow.png" class="arrow"><label for="C">Category Three</label>
<ul>
<li><a href="#">Sub-Category One</a></li>
<li><a href="#">Sub-Category Two</a></li>
<li><a href="#">Sub-Category Three</a></li>
</ul>
</div>
<div class="item">
<input type="checkbox" id="D" />
<img src="https://png.icons8.com/material/50/000000/expand-arrow.png" class="arrow"><label for="D">Category Four</label>
<ul>
<li><a href="#">Sub-Category One</a></li>
<li><a href="#">Sub-Category Two</a></li>
<li><a href="#">Sub-Category Three</a></li>
</ul>
</div>
</div>
</div>