UNPKG

zent

Version:

一套前端设计语言和基于React的实现

190 lines (187 loc) 4.12 kB
/* switch通用 */ .zent-switch { position: relative; display: inline-block; -webkit-box-sizing: border-box; box-sizing: border-box; width: 70px; height: 40px; line-height: 20px; vertical-align: middle; border-radius: 20px; border: 1px solid #999; background-color: #999; cursor: pointer; -webkit-transition: all 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86); transition: all 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86) } .zent-switch:after { position: absolute; width: 34px; height: 34px; left: 2px; top: 2px; border-radius: 100%; background-color: #fff; content: " "; cursor: pointer; -webkit-transition: left 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86); transition: left 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86); } .zent-switch:focus { outline: 0; } .zent-switch:focus:hover { -webkit-box-shadow: none; box-shadow: none; } .zent-switch .zent-switch-inner { color: #fff; font-size: 12px; position: absolute; left: 39px; top: 9px; -webkit-transition: left 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86); transition: left 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86); -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } /* 大小相关 */ .zent-switch-large { height: 50px; line-height: 12px; width: 90px; border-radius: 50px } .zent-switch-large:after { width: 44px; height: 44px; top: 2px; left: 2px; } .zent-switch-large .zent-switch-inner { font-size: 14px; left: 50px; top: 18px; } .zent-switch-large.zent-switch-checked:after { left: 42px; } .zent-switch-large.zent-switch-checked .zent-switch-inner { font-size: 14px; left: 10px; top: 18px; } .zent-switch-small { width: 35px; height: 20px; line-height: 10px } .zent-switch-small:after { width: 16px; height: 16px; top: 1px; left: 1px; } .zent-switch-small .zent-switch-inner { display: none; } .zent-switch-small.zent-switch-checked:after { left: 16px; } /* 状态相关 */ .zent-switch-checked { border-color: #4b0; background-color: #4b0 } .zent-switch-checked::after { left: 32px; } .zent-switch-checked .zent-switch-inner { left: 6px; top: 9px; } .zent-switch-disabled { cursor: not-allowed; background: #f2f2f2; border-color: #f2f2f2 } .zent-switch-disabled.zent-switch-checked { background: #83e5a7; border-color: #83e5a7; } .zent-switch-disabled::after { background: #fff; cursor: not-allowed; } .zent-switch-loading { position: relative; color: transparent; cursor: not-allowed } .zent-switch-loading::after { cursor: not-allowed; } .zent-switch-loading::before { content: ' '; position: absolute; top: 43%; left: 38%; z-index: 2; width: 16px; height: 16px; margin: -5px 0 0 -15px; border: 3px solid rgba(0, 0, 0, 0.2); border-radius: 100%; -webkit-box-sizing: border-box; box-sizing: border-box; border-color: #666 transparent transparent; -webkit-animation: switch-spin 0.6s linear; animation: switch-spin 0.6s linear; -webkit-animation-iteration-count: infinite; animation-iteration-count: infinite; } .zent-switch-loading.zent-switch-checked::before { margin: -5px 0 0 15px; } .zent-switch-loading {/* small switch */ } .zent-switch-loading.zent-switch-small::before { width: 12px; height: 12px; margin: -5px 0 0 -9px; border-width: 2px; } .zent-switch-loading.zent-switch-small.zent-switch-checked::before { margin: -5px 0 0 6px; } .zent-switch-loading {/* large switch */ } .zent-switch-loading.zent-switch-large::before { margin: -5px 0 0 -17px; } .zent-switch-loading.zent-switch-large.zent-switch-checked::before { margin: -5px 0 0 23px; } @-webkit-keyframes switch-spin { 0% { -webkit-transform: rotate(0); transform: rotate(0); } 100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); } } @keyframes switch-spin { 0% { -webkit-transform: rotate(0); transform: rotate(0); } 100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); } }