Last active
January 11, 2016 15:11
-
-
Save tiagodll/6164290 to your computer and use it in GitHub Desktop.
Making an expandable box with nothing but html and css
you can also have only one div, and just change the height of it.
This file contains 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
<style> | |
input[type="checkbox"].expand-content{ display:none; } | |
input[type="checkbox"].expand-content ~ .collapsed { display:block; } | |
input[type="checkbox"].expand-content ~ .expanded { display:none; } | |
input[type="checkbox"].expand-content:checked ~ .collapsed { display:none; } | |
input[type="checkbox"].expand-content:checked ~ .expanded { display:block; } | |
</style> | |
<label> | |
<input type="checkbox" class="expand-content" /> | |
<div class="collapsed">this is the small content</div> | |
<div class="expanded">this is the big content</div> | |
</label> |
Nevermind, it works again. I just changed display:block;
to display:none;
several times.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is very good, I'll embed it in my website. There is however one problem: The first box is always starts expanded while the following start collapsed. Why's that?