我正在使用演示代码,我发现here与Foundation 5.2.3 css版本
<div class="switch">
<input id="exampleCheckboxSwitch" type="checkbox">
<label for="exampleCheckboxSwitch"></label>
</div>
结果如下:
请注意,第二个是我在Foundation 4中使用的代码,它仍然或多或少有效(虽然“On”文本不显示)
<div class="switch small round">
<input id="test" name="test" type="radio" value="False" checked="">
<label for="test" onclick="">Non</label>
<input id="test2" name="test" type="radio" value="True">
<label for="test2" onclick="">Oui</label>
<span></span>
</div>
不确定发生了什么,在文档中说它不需要javascript,交换机的css存在于foundation.css文件中
答案 0 :(得分:1)
尝试使用最新版本的Foundation。这是我的JSFiddle example,其中开关工作正常。
<body>
<div class="row">
<div class="small-12 columns">
<div class="switch">
<input id="exampleCheckboxSwitch" type="checkbox">
<label for="exampleCheckboxSwitch"></label>
</div>
</div>
</div>
</body>
请注意,我使用的是最新的bower-foundation css。
答案 1 :(得分:0)
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked>
<label class="onoffswitch-label" for="myonoffswitch">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
需要CSS:
.onoffswitch {
position: relative; width: 90px;
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
display: block; overflow: hidden; cursor: pointer;
border: 2px solid #999999; border-radius: 20px;
}
.onoffswitch-inner {
display: block; width: 200%; margin-left: -100%;
-moz-transition: margin 0.3s ease-in 0s; -webkit-transition: margin 0.3s ease-in 0s;
-o-transition: margin 0.3s ease-in 0s; transition: margin 0.3s ease-in 0s;
}
.onoffswitch-inner:before, .onoffswitch-inner:after {
display: block; float: left; width: 50%; height: 30px; padding: 0; line-height: 30px;
font-size: 14px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
}
.onoffswitch-inner:before {
content: "ON";
padding-left: 10px;
background-color: #34A7C1; color: #FFFFFF;
}
.onoffswitch-inner:after {
content: "OFF";
padding-right: 10px;
background-color: #EEEEEE; color: #999999;
text-align: right;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
margin-left: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
right: 0px;
}
此示例位于https://proto.io/freebies/onoff/
对不起,我的英文:),但是这个想法。