UNPKG

antd-mobile

Version:

基于 React 的移动设计规范实现

86 lines (83 loc) 1.7 kB
@import '../../style/mixins'; @import '../../style/themes/default'; @switchPrefixCls: am-switch; .@{switchPrefixCls} { display: inline-block; vertical-align: middle; width: 102px; height: 62px; box-sizing: border-box; position: relative; cursor: pointer; .align-self(center); .checkbox { width: 102px; height: 62px; border-radius: 62px; box-sizing: border-box; background: #e5e5e5; z-index: 0; margin: 0; padding: 0; appearance: none; border: 0; cursor: pointer; position: relative; transition: all 300ms; &:before { content: ' '; position: absolute; left: 3px; top: 3px; width: 96px; height: 56px; border-radius: 56px; box-sizing: border-box; background: @fill-base; z-index: 1; transition: all 200ms; .transform(scale(1)); } &:after { content: ' '; height: 56px; width: 56px; border-radius: 56px; background: @fill-base; position: absolute; z-index: 2; left: 3px; top: 3px; .transform(translateX(0px)); transition: all 200ms; .box-shadow(4px 4px 8px @color-shadow); } } input[type="checkbox"] { position: absolute; top: 0; left: 0; opacity: 0; width: 100%; height: 100%; z-index: 2; border: 0 none; appearance: none; &:checked { &+ .checkbox { background: @switch-fill; &:before { .transform(scale(0)); } &:after { .transform(translateX(40px)); } } } &:disabled { &+ .checkbox { opacity: @opacity-disabled; } } } }