Skip to content

Instantly share code, notes, and snippets.

Created Jul 4, 2021
What would you like to do?
.tabh1 + label, .tabh2 + label, .tabh3 + label { padding: 2px 8px; border: solid 1px lightgray; display: inline-block; border-bottom: none; }
.tabh1:checked + label, .tabh2:checked + label, .tabh3:checked + label { background: olivedrab; }
.tabh1, .tabh2, .tabh3 { display: none;}
.tabc1, .tabc2, .tabc3 { display: none; padding: 20px; border: solid 1px lightgray;}
.tabh1:checked ~ .tabc1, .tabh2:checked ~ .tabc2, .tabh3:checked ~ .tabc3 { display: block; }
<input id='th1' type='radio' name='tswitcher' class='tabh1' checked></input>
<label for="th1">tab1</label>
<input id='th2' type='radio' name='tswitcher' class='tabh2'></input>
<label for="th2">tab2</label>
<input id='th3' type='radio' name='tswitcher' class='tabh3'></input>
<label for="th3">tab3</label>
<div class='tabc1'>Content tab 1</div>
<div class='tabc2'>Content tab 2</div>
<div class='tabc3'>Content tab 3</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment