样式单选按钮-在IE和Firefox中不起作用 [英] Styling radio button - not work in IE and Firefox

查看:103
本文介绍了样式单选按钮-在IE和Firefox中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试制作自己的单选按钮样式.在Chrome浏览器中一切正常,但是在IE和Firefox中仍然存在一些显示错误.

I have tried to make own style of radio button. Everything works well in Chrome, but in IE and Firefox there are still some display errors.

这是代码:

HTML

<input type="radio" id ="light" name="choice" value="none""><label for="light">Light me</label>

CSS

input[type="radio"] {
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
background:url('http://refundfx.com.au/uploads/image/checkbox_empty.png') center center no-repeat;
background-size: 2em;
width: 2em;
height: 2em;
cursor: pointer;
vertical-align: middle;
}​

怎么了?

非常感谢您的回答.

推荐答案

尝试一下: jsfiddle

您需要做的是隐藏单选按钮,仅使用标签进行切换.因此,我将input[type="radio"]设置为display:none,并将一些CSS移至label选择器或按钮的新选择器,并将类"button"移至该按钮:

What you need to do is hide the radio button and only use the label for toggling it. So, I set input[type="radio"] to display:none, and moved some of the CSS to the label selector or a new selector for the button, to which I gave the class 'button':

HTML:

<input type="radio" id ="light" name="choice" value="none"">
<label for="light">
<span class="button"></span>
Light me
</label>​​​

CSS:

input[type="radio"] {
    display:none;
}
.button {   background:url('http://refundfx.com.au/uploads/image/checkbox_empty.png') center center no-repeat;
    background-size: 2em;
    width: 2em;
    height: 2em;
    float:left;
}
label { 
    cursor: pointer;
    line-height:32px;
}
​

以下是使用CSS样式化输入的很好的演练:

Here's a good walk through of stylizing inputs with CSS: http://www.wufoo.com/2011/06/13/custom-radio-buttons-and-checkboxes/

这篇关于样式单选按钮-在IE和Firefox中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆