一番上のメニュー1だけ、最初からオープンにしたいのですが、
どのように指定すれば良いのでしょうか。
ご教示いただけますと幸いです。
<div class="cp_actab"> <input id="tab-one" type="checkbox" name="tabs"> <label for="tab-one">メニュー1</label> <div class="cp_actab-content"> <p>こちらのテキストを最初からオープンにしておきたいです!</p> </div> </div> <div class="cp_actab"> <input id="tab-two" type="checkbox" name="tabs"> <label for="tab-two">メニュー2</label> <div class="cp_actab-content"> <p>テキストテキスト</p> </div> </div> <div class="cp_actab"> <input id="tab-three" type="checkbox" name="tabs"> <label for="tab-three">メニュー3</label> <div class="cp_actab-content"> <p>テキストテキスト</p> </div> </div> <div class="cp_actab"> <input id="tab-four" type="checkbox" name="tabs"> <label for="tab-four">メニュー4</label> <div class="cp_actab-content"> <p>テキストテキスト</p> </div> </div>CSS
.cp_actab {
position: relative;
overflow: hidden;
width: 100%;
margin: 0 auto;
color: #ffffff;
}
.cp_actab input {
position: absolute;
z-index: -1;
opacity: 0;
}
.cp_actab label {
line-height: 3;
position: relative;
display: block;
padding: 0 0 0 1em;
cursor: pointer;
margin: 0 0 1px 0;
background: #808080;
}
.cp_actab .cp_actab-content {
overflow: hidden;
max-height: 0;
-webkit-transition: max-height 0.35s;
transition: max-height 0.35s;
color: #333333;
background: #f5f5f5;
}
.cp_actab .cp_actab-content p {
margin: 1em;
}
/* :checked /
.cp_actab input:checked ~ .cp_actab-content {
max-height: 120em;
}
/ Icon */
.cp_actab label::after {
line-height: 3;
position: absolute;
top: 0;
right: 0;
display: block;
width: 3em;
height: 3em;
-webkit-transition: all 0.35s;
transition: all 0.35s;
text-align: center;
}
.cp_actab input[type=checkbox] + label::after {
content: '+';
}
.cp_actab input[type=checkbox]:checked + label::after {
transform: rotate(315deg);
}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/08/13 02:31
2019/08/13 02:42 編集
2019/08/13 03:29
2019/08/13 03:30