First Tab text
Second Tab text
Third Tab text
Force Tab text
<div class="cp_tab">
<input type="radio" name="cp_tab" id="tab3_1" aria-controls="first_tab03" checked>
<label for="tab3_1">First Tab</label>
<input type="radio" name="cp_tab" id="tab3_2" aria-controls="second_tab03">
<label for="tab3_2">Second Tab</label>
<input type="radio" name="cp_tab" id="tab3_3" aria-controls="third_tab03">
<label for="tab3_3">Third Tab</label>
<input type="radio" name="cp_tab" id="tab3_4" aria-controls="force_tab03">
<label for="tab3_4">Force Tab</label>
<div class="cp_tabpanels">
<div id="first_tab03" class="cp_tabpanel">
<h2>First Tab</h2>
<p>First Tab text</p>
</div>
<div id="second_tab03" class="cp_tabpanel">
<h2>Second Tab</h2>
<p>Second Tab text</p>
</div>
<div id="third_tab03" class="cp_tabpanel">
<h2>Third Tab</h2>
<p>Third Tab text</p>
</div>
<div id="force_tab03" 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_tabpanels {
position: relative;
min-height: 150px;/* エリアの高さ */
}
.cp_tab .cp_tabpanel {
position: absolute;
width: 100%;
opacity: 0;
padding: 0.5em 1em;
transform: translateY(-10px);
-webkit-transition: opacity 0.5s, -webkit-transform 0.5s;
transition: opacity 0.5s, -webkit-transform 0.5s;
transition: transform 0.5s, opacity 0.5s;
transition: transform 0.5s, opacity 0.5s, -webkit-transform 0.5s;
}
.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) {
opacity: 1;
transform: translateY(0px);
}
.cp_tab > input:first-child:checked ~ .cp_tabpanels > .cp_tabpanel:first-child {
background: #80CBC4;
}
.cp_tab > input:nth-child(3):checked ~ .cp_tabpanels > .cp_tabpanel:nth-child(2) {
background: #90CAF9;
}
.cp_tab > input:nth-child(5):checked ~ .cp_tabpanels > .cp_tabpanel:nth-child(3) {
background: #F48FB1;
}
.cp_tab > input:nth-child(7):checked ~ .cp_tabpanels > .cp_tabpanel:nth-child(4) {
background: #8BC34A;
}
.cp_tab > label {
position: relative;
display: inline-block;
padding: 5px 10px;
cursor: pointer;
border-radius: 6px 6px 0 0;
font-weight: bold;
}
.cp_tab > input:first-child + label {
background: #80CBC4;
}
.cp_tab > input:nth-child(3) + label {
background: #90CAF9;
}
.cp_tab > input:nth-child(5) + label {
background: #F48FB1;
}
.cp_tab > input:nth-child(7) + label {
background: #8BC34A;
}
.cp_tab > label:hover {
color: #0066cc;
}
.cp_tab > input:focus + label {
color: #ffffff;
}
.cp_tab > input:checked + label {
margin-bottom: -1px;
}
@media (max-width: 480px) {
.cp_tab {
width: 100%;
font-size: 0.8em;
}
.cp_tab label {
padding: 0.5em;
}
}