在应用自动生成的代码时,您还需在html中引入如下CSS
1)引入css:bootstrap.min.css
2)引入如下开关ON/OFF CSS
<style type="text/css">
.onoffswitch {
-moz-user-select: none;
position: relative;
width: 54px;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
border: 2px solid #1ab394;
border-radius: 3px;
cursor: pointer;
display: block;
overflow: hidden;
}
.onoffswitch-inner {
display: block;
margin-left: -100%;
transition: margin 0.3s ease-in 0s;
width: 200%;
}
.onoffswitch-inner::before, .onoffswitch-inner::after {
box-sizing: border-box;
color: white;
float: left;
font-family: Trebuchet,Arial,sans-serif;
font-size: 10px;
font-weight: bold;
height: 20px;
line-height: 20px;
width: 50%;
}
.onoffswitch-inner::before {
background-color: #1ab394;
color: #ffffff;
content: "ON";
padding-left: 7px;
}
.onoffswitch-inner::after {
background-color: #ffffff;
color: #919191;
content: "OFF";
padding-right: 7px;
text-align: right;
}
.onoffswitch-switch {
background: #ffffff none repeat scroll 0 0;
border: 2px solid #1ab394;
border-radius: 3px;
bottom: 0;
display: block;
margin: 0;
position: absolute;
right: 36px;
top: 0;
transition: all 0.3s ease-in 0s;
width: 18px;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
margin-left: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
right: 0;
}
</style>