我试图折叠一个元素,使其仅在单击隐藏输入的标签时才显示。我希望单击标签时<section>将 更改为display: none。display: block
我有以下样式和 html。
li {
list-style-type: none;
}
li::before {
content: "\00a0+";
}
section.site_navigation {
background-color: #eed;
display: none;
}
input#menu_collapse {
display: none;
}
label[for=menu_collapse] {
display: block;
margin: 5px;
padding: 3px;
background-color: #027;
color: #ffe;
font-weight: bold;
}
input[checked]#menu_collapse + label[for=menu_collapse] + section.site_navigation {
display: block;
}
<input type="checkbox" id="menu_collapse">
<label for="menu_collapse">Menu</label>
<section class="site_navigation">
<p>A lot of stuff</p>
<ul>
<li>Page 1</li>
<li>Page 2</li>
</ul>
</section>
<!-- the section is supposed to appear when the damned label is clicked on -->
这是实时版本的链接。
婷婷同学_
HUX布斯
噜噜哒
慕工程0101907
相关分类