Created
September 11, 2017 13:35
-
-
Save naxmefy/b9b01ddb36569e141194d6199d1e20e2 to your computer and use it in GitHub Desktop.
pure css accordion
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
<div class="pure-accordion"> | |
<div class="half"> | |
<p>Open <strong>multiple</strong></p> | |
<div class="tab"> | |
<input id="tab-one" type="checkbox" name="tabs"> | |
<label for="tab-one">Label One</label> | |
<div class="tab-content"> | |
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tenetur, architecto, explicabo perferendis nostrum, maxime impedit atque odit sunt pariatur illo obcaecati soluta molestias iure facere dolorum adipisci eum? Saepe, itaque.</p> | |
</div> | |
</div> | |
<div class="tab"> | |
<input id="tab-two" type="checkbox" name="tabs"> | |
<label for="tab-two">Label Two</label> | |
<div class="tab-content"> | |
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tenetur, architecto, explicabo perferendis nostrum, maxime impedit atque odit sunt pariatur illo obcaecati soluta molestias iure facere dolorum adipisci eum? Saepe, itaque.</p> | |
</div> | |
</div> | |
<div class="tab"> | |
<input id="tab-three" type="checkbox" name="tabs"> | |
<label for="tab-three">Label Three</label> | |
<div class="tab-content"> | |
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tenetur, architecto, explicabo perferendis nostrum, maxime impedit atque odit sunt pariatur illo obcaecati soluta molestias iure facere dolorum adipisci eum? Saepe, itaque.</p> | |
</div> | |
</div> | |
</div> | |
<div class="half"> | |
<p>Open <strong>one</strong></p> | |
<div class="tab blue"> | |
<input id="tab-four" type="radio" name="tabs2"> | |
<label for="tab-four">Label One</label> | |
<div class="tab-content"> | |
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tenetur, architecto, explicabo perferendis nostrum, maxime impedit atque odit sunt pariatur illo obcaecati soluta molestias iure facere dolorum adipisci eum? Saepe, itaque.</p> | |
</div> | |
</div> | |
<div class="tab blue"> | |
<input id="tab-five" type="radio" name="tabs2"> | |
<label for="tab-five">Label Two</label> | |
<div class="tab-content"> | |
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tenetur, architecto, explicabo perferendis nostrum, maxime impedit atque odit sunt pariatur illo obcaecati soluta molestias iure facere dolorum adipisci eum? Saepe, itaque.</p> | |
</div> | |
</div> | |
<div class="tab blue"> | |
<input id="tab-six" type="radio" name="tabs2"> | |
<label for="tab-six">Label Three</label> | |
<div class="tab-content"> | |
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tenetur, architecto, explicabo perferendis nostrum, maxime impedit atque odit sunt pariatur illo obcaecati soluta molestias iure facere dolorum adipisci eum? Saepe, itaque.</p> | |
</div> | |
</div> | |
</div> | |
</div> |
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
.pure-accordion .half { | |
float: left; | |
width: 50%; | |
padding: 0 1em; | |
} | |
/* Acordeon styles */ | |
.pure-accordion .tab { | |
position: relative; | |
margin-bottom: 1px; | |
width: 100%; | |
color: #fff; | |
overflow: hidden; | |
} | |
.pure-accordion input { | |
position: absolute; | |
opacity: 0; | |
z-index: -1; | |
} | |
.pure-accordion label { | |
position: relative; | |
display: block; | |
padding: 0 0 0 1em; | |
background: #16a085; | |
font-weight: bold; | |
line-height: 3; | |
cursor: pointer; | |
} | |
.pure-accordion .blue label { | |
background: #2980b9; | |
} | |
.pure-accordion .tab-content { | |
max-height: 0; | |
overflow: hidden; | |
background: #1abc9c; | |
-webkit-transition: max-height .35s; | |
-o-transition: max-height .35s; | |
transition: max-height .35s; | |
} | |
.pure-accordion .blue .tab-content { | |
background: #3498db; | |
} | |
.pure-accordion .tab-content p { | |
margin: 1em; | |
} | |
/* :checked */ | |
.pure-accordion input:checked ~ .tab-content { | |
max-height: 10em; | |
} | |
/* Icon */ | |
.pure-accordion label::after { | |
position: absolute; | |
right: 0; | |
top: 0; | |
display: block; | |
width: 3em; | |
height: 3em; | |
line-height: 3; | |
text-align: center; | |
-webkit-transition: all .35s; | |
-o-transition: all .35s; | |
transition: all .35s; | |
} | |
.pure-accordion input[type=checkbox] + label::after { | |
content: "+"; | |
} | |
.pure-accordion input[type=radio] + label::after { | |
content: "\25BC"; | |
} | |
.pure-accordion input[type=checkbox]:checked + label::after { | |
transform: rotate(315deg); | |
} | |
.pure-accordion input[type=radio]:checked + label::after { | |
transform: rotateX(180deg); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment