ps-frame-father
Version:
An enterprise-class UI design language and React components implementation
83 lines (82 loc) • 1.58 kB
CSS
.xSwitch {
display: inline-block;
}
.xSwitch .xSwitchInner {
width: 48px;
height: 24px;
border-radius: 30px;
overflow: hidden;
vertical-align: middle;
position: relative;
display: inline-block;
font-size: 12px;
color: #fff;
background: #ccc;
box-shadow: 0 0 1px #36a6d4;
}
.xSwitch .xSwitchInner.large {
width: 60px;
height: 30px;
}
.xSwitch .xSwitchInner.large .xSwitchAnimatingNode::before {
line-height: 30px;
text-indent: 5px;
}
.xSwitch .xSwitchInner.large .offText {
line-height: 30px;
margin-right: 6px;
}
.xSwitch .xSwitchInner.small {
width: 42px;
height: 21px;
}
.xSwitch .xSwitchInner.small .xSwitchAnimatingNode::before {
line-height: 21px;
text-indent: 3px;
}
.xSwitch .xSwitchInner.small .offText {
line-height: 21px;
margin-right: 4px;
}
.xSwitch .xSwitchInner > input {
visibility: hidden;
}
.xSwitch .xSwitchInner > input:checked + span {
transform: translateX(100%);
}
.xSwitch .xSwitchAnimatingNode {
position: absolute;
top: 0;
left: 0;
border-radius: 50%;
width: 50%;
height: 100%;
transition: all linear 0.2s;
}
.xSwitch .xSwitchAnimatingNode::before {
position: absolute;
top: 0;
left: -100%;
content: attr(data-onText);
width: 200%;
height: 100%;
line-height: 2;
text-indent: 5px;
border-radius: 30px;
background: inherit;
}
.xSwitch .xSwitchAnimatingNode::after {
content: '';
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
border-radius: 50%;
background: #fff;
}
.xSwitch .offText {
line-height: 2;
float: right;
margin-right: 5px;
}