javascript - How do I make CSS accordions collapse when different tab is selected? -
i have combined pure css tab pure css accordion. here sources:
accordion: https://codepen.io/raubaca/pen/pzzpve
tabs: https://css-tricks.com/css3-tabs/
i have pure css accordion on first tab. problem when accordions opened in first tab , tab selected, user can see opened accordion underneath. how collapse accordions when tab selected?
https://jsfiddle.net/lance_bitner/ybtqm1hq/
<div class="w3c"> <div id="tab16"> <a href="#tab16">tab 16</a> <div> <div class="tab"> <input id="tab-one" type="checkbox" name="tabs"> <label for="tab-one">introduction sharepoint</label> <div class="tab-content"> <div> <div class="column2"> <a href=""><img src="../images/classroom1.png"></a> <a href=""><img src="../images/document1.png"></a> <a href=""><img src="../images/presentation1.png"></a> <a href=""><img src="../images/video1.png"></a> </div> </div> </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> <div id="tab17"> <a href="#tab17">tab 17</a> <div>... 30 lines of css rather lot, and...</div> </div> <div id="tab18"> <a href="#tab18">tab 18</a> <div>... 2 should have been enough, but...</div> </div> </div>
use input type radio instead of checkbox.
<input id="tab-four" type="radio" name="tabs2">
you can see example here: https://codepen.io/raubaca/pen/pzzpve
cheers.
wiki
Comments
Post a Comment