简体   繁体   English

IE8 / IE7 中的自定义复选框

[英]Custom Checkboxes in IE8 / IE7

I'm trying to create custom checkboxes for my website and it works fine with >IE9 and other browsers.我正在尝试为我的网站创建自定义复选框,它适用于 >IE9 和其他浏览器。 But it doesn't work as expected in IE8 or 7. Here is my CSS但它在 IE8 或 7 中无法按预期工作。这是我的 CSS

input[type="checkbox"] + label span {
  height: 13px;
  width:13px;
  display: inline-block;
  cursor: pointer;
  background: url("../img/icons.png") no-repeat;
  vertical-align: text-top;
  margin-right: 6px; 
  background-position: -57px -118px; 
}

input[type="checkbox"]:checked + label span{ 
background-position: -70px -106px; 
}

<input type="checkbox" id="chkbox1" value="1" onclick="alert('clicked');">
<label for="chkbox1"><span></span>Checkbox1</label>

It works fine in latest browsers and I downloaded selectivizr.js for fallback to :checked pseudo selectors to work in IE8 / 7 but the problem is that when I click on the checkbox, nothing seems to be happening to the state of the checkbox and even the onclick event is not getting captured.它在最新的浏览器中运行良好,我下载了selectivizr.js以回退到:checked伪选择器以在 IE8 / 7 中工作,但问题是当我单击复选框时,复选框的状态似乎没有发生任何变化,甚至onclick事件没有被捕获。 Any help would be greatly appreciated.任何帮助将不胜感激。

Like Nash3man said it could be a z-index issue.就像 Nash3man 说的那样,这可能是 z-index 问题。 Personnaly for cross-browser custom checkboxes i use this plugin jquery: http://fronteed.com/iCheck/ Personnaly 跨浏览器自定义复选框我使用这个插件 jquery: http : //fronteed.com/iCheck/

Good chance this will work.很有可能这会奏效。 I created them in two hours.我在两个小时内创建了它们。 Tell me if it works.告诉我它是否有效。 I haven't tested them in ie because I don't have an old version of ie available.我没有在 ie 中测试它们,因为我没有旧版本的 ie 可用。

Radio buttons: https://plus.url.google.com/url?q=https://jsfiddle.net/www139/ba5jn2e6/19&rct=j&ust=1438272911487000&usg=AFQjCNGbnoaoAsY0eXLb8k0YBrO3wswiNQ单选按钮: https : //plus.url.google.com/url?q=https : //jsfiddle.net/www139/ba5jn2e6/19&rct=j&ust=1438272911487000&usg=AFQjCNGbnoaoAsY0eXLb8k0YBrO3wswiNQ

Checkboxes: https://plus.url.google.com/url?q=https://jsfiddle.net/www139/wpq6qjyf/76/&rct=j&ust=1438273369508000&usg=AFQjCNG4Tfz0XYteFZAz8Q53OXSevujfNg复选框: https ://plus.url.google.com/url ? q =https : //jsfiddle.net/www139/wpq6qjyf/76/&rct=j&ust=1438273369508000&usg=AFQjCNG4Tfz0XYteFZAz8Q53NOXSevujf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM