zui
Version:
一个基于 Bootstrap 深度定制开源前端实践方案,帮助你快速构建现代跨屏应用。
133 lines (110 loc) • 2.33 kB
text/less
/// ========================================================================
/// ZUI: switch.less
/// http://openzui.com
/// ========================================================================
/// Copyright 2017 cnezsoft.com; Licensed MIT
/// ========================================================================
// Switch base style
.switch {
position: relative;
> input {
opacity: 0;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
margin: 0;
display: block;
}
> label {
display: block;
padding: 5px 0 5px 35px;
line-height: 20px;
font-weight: normal;
margin: 0;
&:before,
&:after {
content: ' ';
display: block;
position: absolute;
left: 0;
top: 5px;
height: 20px;
border-radius: 10px;
border: 1px solid #ddd;
width: 30px;
pointer-events: none;
background-color: @color-white;
.transition-normal();
}
&:after {
width: 18px;
height: 18px;
border-radius: 9px;
top: 6px;
border-color: #ccc;
box-shadow: rgba(0,0,0,.05) 0 1px 4px, rgba(0,0,0,.12) 0 1px 2px;
}
}
> input:checked + label {
&:before {
background-color: @color-primary;
border-color: @color-primary;
}
&:after {
border-color: @color-white;
left: 11px;
}
}
&.text-left {
> label {
padding: 5px 35px 5px 0;
&:before,
&:after {
right: 0;
left: auto;
}
&:after {
right: 12px;
}
}
> input:checked + label {
&:after {
left: auto;
right: 1px;
}
}
}
&.disabled {
pointer-events: none;
}
&.disabled > label,
> input[disabled] + label {
pointer-events: none;
color: @component-disabled-color;
&:before {
background-color: #fafafa;
}
&:after {
opacity: .7;
}
}
&.disabled > input:checked + label,
> input[disabled]:checked + label {
&:before {
border-color: #ccc;
background-color: #ccc;
}
}
input:focus + label {
&:before {
border-color: @color-primary;
box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px @color-primary;
}
}
}
// switch inline
.switch-inline {
display: inline-block;
}