CSS3自定义单选按钮问题

标签 css internet-explorer-7 radio-button

我按照 wittysparks.com 创建自定义单选按钮一切正常,但如果在标签中添加更多内容将显示未使用的图像。

下面的代码正在查找。

    <input id="radio2" name="groupradio" type="radio" value="Radio 2" tabindex="6" /><label     for="radio2">I am Group Radio 2 </br>
</label>

在代码中添加更多内容后会出现问题。

    <input id="radio2" name="groupradio" type="radio" value="Radio 2" tabindex="6" /><label    for="radio2">I am Group Radio 2 </br>
I am Group Radio 2 </br>
I am Group Radio 2 </br>
I am Group Radio 2 </br>
I am Group Radio 2 </br>
I am Group Radio 2 </br>
I am Group Radio 2 </br>
I am Group Radio 2 </br>
I am Group Radio 2 </br>
</label>

这是我的CSS

/*!
 * WittySparks - (c) Sravan Kumar, freely distributable, can modify as per your needs.
 * WittySparks.com.com
 */
input[type='radio'], input[type='checkbox']{opacity:0;position:absolute;filter:alpha(opacity=0);margin:5px 0 0 5px}
input[type='radio']:focus+label, input[type="checkbox"]:focus+label{color:#C30}
input[type="checkbox"]+label, input[type="radio"]+label{background:url('wittysparks_checkbox_radio.png') left top no-repeat;position:relative;margin:0;padding:0 0 0 50px;cursor:pointer;line-height:43px;min-height:43px;display:inline-block;z-index:0;font-size:30px;font-weight:bold}
input[type="checkbox"]+label{background-position:0 0}
input[type="radio"]+label{background-position:0 -200px}
input[type='checkbox']:checked+label{background-position:0 -100px}
input[type='radio']:checked+label{background-position:0 -300px}
input[type='checkbox']:disabled+label{background-position:0 -400px;color:#999}
input[type='radio']:disabled+label{background-position:0 -600px;color:#999} 
input[type='checkbox']:disabled:checked+label{background-position:0 -500px;color:#999}
input[type='radio']:disabled:checked+label{background-position:0 -700px;color:#999}

教程网站。 "http://www.wittysparks.com/2012/04/17/pure-css3-custom-checkbox-and-radio-buttons-with-sprite-image/ "

更新 jsfiddle

http://jsfiddle.net/shivanraptor/fdEHj/1/

最佳答案

CSS 本身受标签高度的影响。如果标签的高度减少到 1 行或两行,问题就消失了。

尝试通过CSS分离label的效果。

关于CSS3自定义单选按钮问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15285550/

相关文章:

html - 根据宽度反转div的顺序

html - 为什么我的 div 不对齐会渲染错误

CSS 菜单在 IE7 中左对齐 - 如何在所有浏览器(IE7、IE8、firefox 等)中使菜单居中

html - 如何使图像上的多个单选按钮响应?

html - 如何设置一个div相对于另一个div的位置

php - 为什么网站在线时我的后台不工作?

css - IE7 中的流体宽度导航

html - CSS 左 : -50% causing IE7 to ignore width

radio-button - MVC 5 RadioButtonFor enum,总是选择默认的枚举值零?

html - 如何通过 "for"属性更新 Prototype 中 <label> 的 innerHTML?