gpt4 book ai didi

css - 复选框图像叠加

转载 作者:行者123 更新时间:2023-11-28 16:34:49 25 4
gpt4 key购买 nike

我需要有关仅使用 CSS 的复选框的帮助。

首先它能正常工作。但是,我想在单击按钮时将选中的图像覆盖在未选中的图像之上。如何实现?

.gchoice_1_1_3 {border: 1px solid red;}

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

.gchoice_1_1_3 input[type="checkbox"] + label:before {
background: url('http://www.uswebcompany.com/plugins/gravityforms/wp-content/uploads/2016/01/christmasLights.png') 0 0px no-repeat;
z-index: 10;
content: "";
display: inline-block;
font-size: 12px;
height: 75px;
width: 75px;
line-height: 16px;
margin: -2px 6px 0 0;
text-align: center;
vertical-align: middle;
positionL relative;
border-radius: 10px;
background-color: #6283B2;
}

.gchoice_1_1_3 input[type="checkbox"]:checked + label:before {
background: url('http://www.uswebcompany.com/plugins/gravityforms/wp-content/uploads/2016/01/checkmark.png') 0 0px no-repeat;
height: 75px;
width: 75px;
border-radius: 10px;
background-color: #37924A;
}
<li class='gchoice_1_1_3'>
<input name='input_1.3' type='checkbox' value='Christmas Lights' id='choice_1_1_3' tabindex='22' />
<label for='choice_1_1_3' id='label_1_1_3'>Christmas Lights</label>
</li>

最佳答案

您可以使用多个背景。
但一定要检查浏览器支持和应用背景的顺序问题。

.gchoice_1_1_3 {border: 1px solid red;}

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

.gchoice_1_1_3 input[type="checkbox"] + label:before {
background: url('http://www.uswebcompany.com/plugins/gravityforms/wp-content/uploads/2016/01/christmasLights.png') 0 0px no-repeat;
z-index: 10;
content: "";
display: inline-block;
font-size: 12px;
height: 75px;
width: 75px;
line-height: 16px;
margin: -2px 6px 0 0;
text-align: center;
vertical-align: middle;
position: relative;
border-radius: 10px;
background-color: #6283B2;
}

.gchoice_1_1_3 input[type="checkbox"]:checked + label:before {
background: url('http://www.uswebcompany.com/plugins/gravityforms/wp-content/uploads/2016/01/checkmark.png'), url('http://www.uswebcompany.com/plugins/gravityforms/wp-content/uploads/2016/01/christmasLights.png') 0 0px no-repeat;
height: 75px;
width: 75px;
border-radius: 10px;
background-color: #37924A;
}
<li class='gchoice_1_1_3'>
<input name='input_1.3' type='checkbox' value='Christmas Lights' id='choice_1_1_3' tabindex='22' />
<label for='choice_1_1_3' id='label_1_1_3'>Christmas Lights</label>
</li>

关于css - 复选框图像叠加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34730553/

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