I want to use CSS only to show a div when clicked on another div
Here is my HTML code
<div id="contentmenu">
<div class="show">
<a class="show">
My Student
</a>
</div>
<div class="hidden">
<a href="#">Link 1</a><br/>
<a href="#">Link 2</a><br/>
<a href="#">Link 3</a><br/>
</div>
</div>
My CSS code is
#contentmenu{
margin-top: 79px;
background-color: #E9D4B5;
width: 25%;
height: 100%;
}
.show{
margin-top: 2%;
background-color: #CE9127;
width: 96%;
height: 10%;
padding-left: 4%;
color: white;
text-decoration: none;
}
.hidden{
display: none;
padding-left: 8%;
margin-top: 1%;
}
So how to display div (class = hidden) when clicked on the div (class = show) using CSS only
You could do it with the Checkbox Hack, though be sure to make sure browser support is sufficient. It would look like this:
with this HTML:
Here is a demo: http://jsbin.com/exuvez/1/edit