css - 如何使用复选框 : different outputs according to element id or class? 隐藏带有 css 的元素

标签 css

我有this code应该根据特定的复选框显示和隐藏元素输出。

我得到的输出是每个复选框在单击时显示的输出比应有的多。

如何使用特定的 css ID 来定位它们?

我的意思是,当您点击每个框时,它应该只显示引用该特定框的文本,而不是所有框。

感谢您的见解!!

罗莎蒙达

最佳答案

DEMO

/*styled relative to the label*/
label {display:block;}
label ~ div {display:none; margin-left:1em;}

/*targetting*/
/*boxes with id having this number will style a sibling div with this number*/
input[type="checkbox"][id*="131"]:checked ~ div[class*="131"] {display:inline;}
input[type="checkbox"][id*="134"]:checked ~ div[class*="134"] {display:inline;}
input[type="checkbox"][id*="130"]:checked ~ div[class*="130"] {display:inline;}

关于css - 如何使用复选框 : different outputs according to element id or class? 隐藏带有 css 的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9756011/

相关文章:

performance - 在特定 URL 上加载自定义字体

css - 如何处理包含大量内容的响应式 bootstrap 3 表?

html - 将 div 排列为网格

css - 在 Bootstrap 4 中禁用列换行

css - 在不缩放的情况下裁剪图像高度

javascript - 连接 Bootstrap、jQuery 和本地 JavaScript - 破坏 jQuery

html - 高度随::after 和相对定位变化

javascript - 如何将空间视为角色

html - 如何使具有不同行数的2个不同表具有相同的高度

jquery - 如何使用 jQuery Draggable 的高级方法