【发布时间】:2014-07-29 22:00:10
【问题描述】:
您好,我有不同的复选框,我想要一个图像而不是复选框,所以如果我单击图像,背景应该会改变,以指示它是否被选中。
因为我有不同的复选框,所以我不能将背景作为图像放在 CSS 中。 请建议我应该如何继续。
【问题讨论】:
您好,我有不同的复选框,我想要一个图像而不是复选框,所以如果我单击图像,背景应该会改变,以指示它是否被选中。
因为我有不同的复选框,所以我不能将背景作为图像放在 CSS 中。 请建议我应该如何继续。
【问题讨论】:
见Here。您可以将其应用于您的代码并具有自定义背景
HTML:
<div class="amPmCheckbox">
<input type="checkbox" name="data[Child][remember_me]" class="checkboxLabel main_street_input" id="am_2" value="1" />
<label for="am_2">AM</label>
</div>
CSS:
.amPmCheckbox input[type="checkbox"] {
display: none;
}
.amPmCheckbox input[type="checkbox"]+label {
background: url('http://renegadeox.com/img/off.png') no-repeat;
height:17px;
padding-left: 18px;
}
.amPmCheckbox input[type="checkbox"]:checked + label {
background: url('http://renegadeox.com/img/on.png') no-repeat;
height:17px;
}
【讨论】: