gpt4 book ai didi

html - 我可以唯一地标识 2 个复选框,以便我可以为每个复选框添加不同的图像吗?

转载 作者:太空宇宙 更新时间:2023-11-04 11:46:00 24 4
gpt4 key购买 nike

目前,我正在为已选中和未选中的复选框使用图像,html 和 css 位于下方。

<div class="text-field-box text-field-box-mobile radio-button-box small">

<asp:CheckBox ID="ChkOffer1" text=" " runat="server" class="checkbox checkbox-mobile radio" Visible="true" EnableViewState="true"></asp:CheckBox>
<% Response.Write(Session("Offer1"))%>
</div>

和CSS

                input[type=checkbox] {
display:none;
}
input[type=checkbox] + label
{
background-image: url("checkbox-default.png");
background-repeat: no-repeat;
height: 25px;
width: 25px;

padding: 0 0 0 0px;
padding-left:30px;
}

input[type=checkbox]:checked + label
{
background-image: url("checkbox-checked.png");
background-repeat: no-repeat;
height: 25px;
width: 25px;

padding: 0 0 0 0px;
padding-left:30px;
}

我想做的是找到一种可以唯一标识每个复选框的方法,这样我就可以有两个带有两个不同图像的复选框字段。

这些是我失败的尝试 我尝试添加一个名为 radio 的额外类像这样。 input.radio[type=checkbox]我还尝试将 radio 类添加到标签中,如下所示 input[type=checkbox] + label.radio

然后对 ID 进行了同样的尝试,但每次都失败了。有人能解决我的问题吗?

最佳答案

这是我的意思的一个例子:

(哦,请原谅图片:))

#field1,#field2{
display:none;
}

#field1 + label {
padding:40px;
padding-left:100px;
background:url(http://www.clker.com/cliparts/M/F/B/9/z/O/nxt-checkbox-unchecked-md.png) no-repeat left center;
background-size: 80px 80px;
}

#field1:checked + label {
background:url(http://www.clker.com/cliparts/B/2/v/i/n/T/tick-check-box-md.png) no-repeat left center;
background-size: 80px 80px;
}

#field2 + label {
padding:40px;
padding-left:100px;
background:url(http://www.adventureswithwords.com/wp-content/uploads/2014/11/unhappy_face_sticker-p217427116611791537qjcl_400-390x390.jpg) no-repeat left center;
background-size: 80px 80px;
}

#field2:checked + label {
background:url(https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRXWLioYfp2eZyyJ2g2VQM2YJd_PwFxrB-DDbZx1WwM8wXo20STCcDung) no-repeat left center;
background-size: 80px 80px;
}
<input type="checkbox" id="field1"/>
<label for="field1">Label</label>

<input type="checkbox" id="field2"/>
<label for="field2">Label</label>

关于html - 我可以唯一地标识 2 个复选框,以便我可以为每个复选框添加不同的图像吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30985234/

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