accordion css only
by marusti
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<section>
<div class="tab">
<input id="tab-one" type="radio" 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="radio" name="tabs">
<label for="tab-two">Label Two</label>
<div class="tab-content"><img src="https://sbarthel.github.io/images/img/berg.JPG" alt="mountain" />
<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="radio" 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>
</section>
CSS
body {
color: #2c3e50;
background: #ecf0f1;
}
section {
display: -webkit-flex;
display: flex;
-webkit-flex-direction: column;
flex-direction: column;
}
/* Acordeon styles */
.tab {
position: relative;
margin-bottom: 1px;
color: #fff;
overflow: hidden;
}
input {
position: absolute;
opacity: 0;
z-index: -1;
}
label {
position: relative;
display: block;
padding: 0 0 0 1em;
background: #3c8dc5;
font-weight: bold;
line-height: 3;
cursor: pointer;
}
.tab-content {
display: -webkit-flex;
display: flex;
max-height: 0;
overflow: hidden;
background: #fff;
-webkit-transition: max-height .35s;
-o-transition: max-height .35s;
transition: max-height .35s;
}
.tab-content p {
color: #333;
margin: 1em;
}
.tab-content img {
padding: 1em
}
/* :checked */
input:checked ~ .tab-content {
max-height: 10em;
}
/* Icon */
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;
}
input[type=radio] + label::after {
font-family: FontAwesome;
content: "\f067";
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;
}
input[type=radio]:checked + label::after {
font-family: FontAwesome;
content: "\f068";
}
@media only screen and (min-width: 768px) {
}
img {
max-width: 100%;
height: auto
}