我正在使用CSS3为这样的复选框设置样式 site (幻灯片三)
HTML:
<div class="slideThree">
<input type="checkbox" id="slideThree" name="check" />
<label for="slideThree"></label>
</div>
的CSS:
input[type=checkbox] {
visibility: hidden;
}
/* SLIDE THREE */
.slideThree {
width: 91px;
height: 26px;
background: #2B3D61;
margin: 5px;
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
border-radius: 50px;
position: relative;
-webkit-box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,0.2);
-moz-box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,0.2);
box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,0.2);
}
.slideThree:after {
content: 'OFF';
font: 14px/26px Arial, sans-serif;
color: #FFF;
position: absolute;
right: 10px;
z-index: 0;
font-weight: bold;
text-shadow: 1px 1px 0px rgba(255,255,255,.15);
}
.slideThree:before {
content: 'ON';
font: 14px/26px Arial, sans-serif;
color: #FFF;
position: absolute;
left: 10px;
z-index: 0;
font-weight: bold;
}
.slideThree label {
display: block;
width: 45px;
height: 24px;
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
border-radius: 50px;
-webkit-transition: all .4s ease;
-moz-transition: all .4s ease;
-o-transition: all .4s ease;
-ms-transition: all .4s ease;
transition: all .4s ease;
cursor: pointer;
position: absolute;
top: 1px;
left: 3px;
z-index: 1;
-webkit-box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.3);
-moz-box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.3);
box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.3);
background: #fcfff4;
background: -webkit-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
background: -moz-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
background: -o-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
background: -ms-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
background: linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fcfff4', endColorstr='#b3bead',GradientType=0 );
}
.slideThree input[type=checkbox]:checked + label {
left: 44px;
}
IE8不支持此处的内容。 编辑我有一个DOCTYPE
而我已删除z-index
但这一切都没有改变。复选框仍然无法正常工作。有没有办法绕过这个或我需要在我的HTML中使用条件css?如果它降级为一个简单的复选框,那么IE8就可以了。
答案 0 :(得分:1)
解决此问题的方法是为:after
和:before
声明创建一个额外的类名,并使用JavaScript根据事件添加/删除这些类。
答案 1 :(得分:0)
在标签前和标签后添加范围:
<label for="slideThree"></label><span class="on">On</span><span class="off">Off</span>
.on的CSS:
font: 14px/26px Arial, sans-serif;
color: #FFF;
position: absolute;
left: 10px;
z-index: 0;
font-weight: bold;
.off的CSS:
font: 14px/26px Arial, sans-serif;
color: #FFF;
position: absolute;
right: 10px;
z-index: 0;
font-weight: bold;
text-shadow: 1px 1px 0px rgba(255,255,255,.15);
答案 2 :(得分:0)
我带着脏的(我的意思是拉斯维加斯脏)IE条件覆盖css,让它回到一个复选框。
又名
<!--[if lt IE 9]> <link rel="stylesheet" href="default-ie.css" type="text/css" /> <![endif]-->