First Tab text
Second Tab text
Third Tab text
Force Tab text
<div class="cp_tab">
<input type="radio" name="cp_tab" id="tab1_1" aria-controls="first_tab01" checked>
<label for="tab1_1">First Tab</label>
<input type="radio" name="cp_tab" id="tab1_2" aria-controls="second_tab01">
<label for="tab1_2">Second Tab</label>
<input type="radio" name="cp_tab" id="tab1_3" aria-controls="third_tab01">
<label for="tab1_3">Third Tab</label>
<input type="radio" name="cp_tab" id="tab1_4" aria-controls="force_tab01">
<label for="tab1_4">Force Tab</label>
<div class="cp_tabpanels">
<div id="first_tab01" class="cp_tabpanel">
<h2>First Tab</h2>
<p>First Tab text</p>
</div>
<div id="second_tab01" class="cp_tabpanel">
<h2>Second Tab</h2>
<p>Second Tab text</p>
</div>
<div id="third_tab01" class="cp_tabpanel">
<h2>Third Tab</h2>
<p>Third Tab text</p>
</div>
<div id="force_tab01" class="cp_tabpanel">
<h2>Force Tab</h2>
<p>Force Tab text</p>
</div>
</div>
</div>
.cp_tab *, .cp_tab *:before, .cp_tab *:after {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.cp_tab {
margin: 1em auto;
}
.cp_tab > input[type='radio'] {
margin: 0;
padding: 0;
border: none;
border-radius: 0;
outline: none;
background: none;
-webkit-appearance: none;
appearance: none;
display: none;
}
.cp_tab .cp_tabpanel {
display: none;
}
.cp_tab > input:first-child:checked ~ .cp_tabpanels > .cp_tabpanel:first-child,
.cp_tab > input:nth-child(3):checked ~ .cp_tabpanels > .cp_tabpanel:nth-child(2),
.cp_tab > input:nth-child(5):checked ~ .cp_tabpanels > .cp_tabpanel:nth-child(3),
.cp_tab > input:nth-child(7):checked ~ .cp_tabpanels > .cp_tabpanel:nth-child(4),
.cp_tab > input:nth-child(9):checked ~ .cp_tabpanels > .cp_tabpanel:nth-child(5),
.cp_tab > input:nth-child(11):checked ~ .cp_tabpanels > .cp_tabpanel:nth-child(6) {
display: block;
}
.cp_tab > label {
position: relative;
display: inline-block;
padding: 15px;
cursor: pointer;
border: 1px solid transparent;
border-bottom: 0;
}
.cp_tab > label:hover,
.cp_tab > input:focus + label {
color: #0066cc;
}
.cp_tab > input:checked + label {
margin-bottom: -1px;
border-color: #cccccc;
border-bottom: 1px solid #ffffff;/*背景色と同じ*/
border-radius: 6px 6px 0 0;
}
.cp_tab .cp_tabpanel {
padding: 0.5em 1em;
border-top: 1px solid #cccccc;
}
@media (max-width: 480px) {
.cp_tab {
width: 100%;
font-size: 0.8em;
}
.cp_tab label {
padding: 0.5em;
}
}