<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 6 年前。
<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 6 年前。
我有这个CodePen测试 DropDown 侧边栏。
不使用 JS,仅使用纯 CSS,如果单击隐藏的 input
复选框类型,则显示/隐藏 ul
。
除了选择要显示/隐藏的 ul
之外,它的工作原理是因为从选中的输入中选择同一级别的所有 ul
需要帮助来应用正确的选择器
这个 dropdown input:checked ~ ul
选择所有的 ul,但是这个 dropdown input:checked ~ ul:first-child
没有选择任何!
代码可用here
最佳答案
不要使用 input ~ ul
因为这意味着“输入后的任何 ul”
而是使用 input + label + ul
来具体表示“在输入之后的标签之后的 ul”。
关于CSS 多重伪选择器和波浪号,如何,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38171594/