gpt4 book ai didi

html - CSS:自定义复选框不起作用

转载 作者:搜寻专家 更新时间:2023-10-31 22:18:19 24 4
gpt4 key购买 nike

我有一个基本的自定义复选框,我需要该框在单击该框时将状态更改为已选中,但它不起作用。有人可以帮我找出问题吗?

input[type=checkbox] {
display: none;
}

input[type=checkbox] + .accord-text:before {
display: block;
content: "☐";
width: 30px;
height: 30px;
color: green;
}

input[type=checkbox]:checked + .accord-text:before {
content: "☑";
}
<lable for='product-45-45'>
<input type='checkbox' style="float:right;"/>
<div class="accord-text">
<strong>header:</strong> sub text
<strong>more text!</strong>
</div>
</lable>

最佳答案

您必须链接您的标签(请注意它拼错了lable)forinput id 让它工作 - 请看下面的演示:

input[type=checkbox] {
display: none;
}
input[type=checkbox] + .accord-text:before {
display: block;
content: "☐";
width: 30px;
height: 30px;
color: green;
}
input[type=checkbox]:checked + .accord-text:before {
content: "☑";
}
<label for='product-45-45'>
<input type='checkbox' style="float:right;" id='product-45-45'/>
<div class="accord-text">
<strong>header:</strong> sub text
<strong>more text!</strong>
</div>
</label>

关于html - CSS:自定义复选框不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41826118/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com