CSS:仅限样式复选框标签

时间:2013-04-29 07:21:16

标签: css css3

有没有什么方法可以在css上选择仅用于复选框的标签?

我正在使用此css代码     输入[类型="无线电&#34],     输入[类型="复选框"]     {         位置:绝对;左:-999em;     }

label:before 
{ 
    display: inline-block; position: relative; top:0.25em; left:-2px; 
    content:''; width:25px; height:25px;
    background-image:url(formelements.png); 
}

input[type="checkbox"] + label:before 
{ 
    background-position: 0 -25px;
}         
input[type="checkbox"]:checked + label:before 
{
    background-position: 0 0 ; 
}
input[type="radio"] + label:before 
{ 
    background-position: -25px -25px;
} 
input[type="radio"]:checked + label:before 
{
    background-position: -25px 0;
}

如果您想要图像,可以从here获取图像,并且可以找到我正在关注样式的指南here 但我面临的问题是所有输入的所有标签都会受到影响。有没有办法只设置那些用于复选框的标签?

谢谢你

1 个答案:

答案 0 :(得分:0)

复选框标签的自定义CSS。适用于我的情况:

.medview input[type="checkbox"][class="selectorThumbs"] + label:before {
    background: url('../icons/thumbs.png') no-repeat;
}
.medview input[type="checkbox"][class="selectorThumbs"]:checked + label:before {
    background: url('../icons/thumbs1.png') no-repeat;
}
相关问题