【发布时间】:2014-08-12 13:35:09
【问题描述】:
提前感谢您! Javascript 新手。
我需要开发位于 div 内的自定义复选框,当您单击标签或复选框时,div 的边框和字体颜色会发生变化。以为我可以用 CSS 做到这一点,但我开始认为我需要 JS。
到目前为止,这是我的代码:
CSS:
input[type=checkbox] {
display: none;
}
div.label {
display:block;
border: 1px solid gray;
border-radius: 23px;
line-height: 30px;
height:50px;
width: 225px;
text-align:center;
}
label {
color:gray;
line-height:50px;
}
label:before {
content: "";
display: inline-block;
width: 13px;
height: 13px;
margin-right: 10px;
background-color: #ffffff;
}
input[type=checkbox]:checked + label:before {
content: "\2713";
font-size: 15px;
color: red;
line-height: 15px;
margin-left:10px;
margin-top: 15px;
}
input[type=checkbox]:checked + label:after {
color: red;
}
HTML:
<div class="label">
<input id="weekly" type="checkbox" name="lists[weekly]" value="True" />
<label for="weekly">Weekly Preview Email</label><br>
</div>
非常感谢任何帮助!
【问题讨论】:
-
js 还是借助 jquery??
-
没关系,只要有效!此外,刚刚编辑以注意标签也在带有复选框的 div 内。谢谢!
-
你想要它在 CSS 中吗?它is possible
-
如果可能的话,当然!谢谢!
标签: javascript css checkbox