I have tried all the questions and answers related to this topic. Additionally, I attempted to solve related questions but was not successful. Please read my question thoroughly.
What I Want:
When I click on the
click me
Div, the secondhiddendiv
Div is displayed. However, I want it so that when I click again on theclick me
Div, thehiddendiv
Div is hidden. I am looking for a similar toggle event using only CSS.Similarly, when I click on the
click me
Div, the secondhiddendiv
Div is displayed. But if I click on any other area, I want thehiddendiv
Div not to be hidden. I need a solution using only CSS.
Please provide solutions using only pure CSS and CSS3 without JavaScript, jQuery, or any other form of control.
The Code:
.clicker {
width: 100px;
height: 100px;
background-color: blue;
outline: none;
cursor: pointer;
color:#FFF;
}
.hiddendiv {
display: none;
height: 200px;
background-color: green;
}
.clicker:focus+.hiddendiv {
display: block;
}
<div>
<div class="clicker" tabindex="1">Click me</div>
<div class="hiddendiv"></div>
</div>