单选按钮背景图像

Sow*_*mya 10 css html5 css3

我给了单选按钮的bg图像.它使用的是chrome,但不是mozilla.

这是我的代码

 <div class="fieldlist">
    <label for="shipadd2">
    <input type="radio" id="shipadd2" name="address" />   
    <div class="compacttext"> Lorem ipsum </div>
    </label>
  </div>
Run Code Online (Sandbox Code Playgroud)

CSS是

.fieldlist input[type="radio"] {
    float: right;
    -webkit-appearance: none;
    border: none;
    width: 25px;
    height: 25px;
    background: url(images/radio.png) left center no-repeat;    
    background-size: 20px; 
}
.fieldlist input[type="radio"]:checked {
    background: url(images/radio_checked.png) left center no-repeat;

}
Run Code Online (Sandbox Code Playgroud)

san*_*eep 29

像这样写:

CSS:

input[type="radio"]{
    display:none;
}

input[type="radio"] + label
{
    background: #999;
    height: 16px;
    width: 16px;
    display:inline-block;
    padding: 0 0 0 0px;
}

input[type="radio"]:checked + label
{
    background: #0080FF;
    height: 16px;
    width: 16px;
    display:inline-block;
    padding: 0 0 0 0px;
}
Run Code Online (Sandbox Code Playgroud)

HTML

<input type="radio" id="shipadd2" name="address" />
<label for="shipadd2"></label>
Run Code Online (Sandbox Code Playgroud)

阅读这篇文章了解更多信息http://css-tricks.com/the-checkbox-hack/