Created
October 11, 2019 19:59
-
-
Save LironHazan/a14a801bb55ca069e982d3b645347126 to your computer and use it in GitHub Desktop.
checked state - show hide legend by css only
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input[type=checkbox] { | |
display: none; | |
} | |
.toggle-legend { | |
cursor: pointer; | |
} | |
input[type=checkbox]:checked ~ .groups-legend { | |
display: flex; | |
} | |
input:not(:checked) ~ .groups-legend { | |
display: none; | |
} | |
.groups-legend { | |
// display: none; | |
position: absolute; | |
align-items: center; | |
transition: width 0.3s linear; | |
.legend { | |
display: flex; | |
align-items: center; | |
width: 120px; | |
.color { | |
width: 20px; | |
height: 20px; | |
background-color: #00a3d2; | |
} | |
.text { | |
margin-left: 10px; | |
} | |
} | |
} | |
<input type="checkbox" id="toggle-legend" checked> | |
<label class="toggle-legend" for="toggle-legend">Legend</label> | |
<div class="groups-legend"> | |
<div class="legend"> | |
<div class="color"></div> | |
<div class="text"> text </div> | |
</div> | |
<div class="legend"> | |
<div class="color"></div> | |
<div class="text"> text </div> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment