UNPKG

weui

Version:

A UI library by WeChat official design team, includes the most useful widgets/modules in mobile web applications.

83 lines (77 loc) 2.23 kB
/* * Tencent is pleased to support the open source community by making WeUI available. * * Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. * * Licensed under the MIT License (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://opensource.org/licenses/MIT * * Unless required by applicable law or agreed to in writing, software distributed under the License is * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language governing permissions and * limitations under the License. */ @import "../../base/fn"; .weui-cell_switch { padding-top: (@weuiCellHeight - @weuiSwitchHeight) / 2; padding-bottom: (@weuiCellHeight - @weuiSwitchHeight) / 2; &.weui-cell_readonly, &.weui-cell_disabled { color: var(--weui-FG-3); } } .weui-switch { appearance: none; } .weui-switch, .weui-switch-cp__box { vertical-align: bottom; position: relative; width: 52px; height: @weuiSwitchHeight; background-color: var(--weui-FG-3); border: 0; padding: 2px; outline: 0; border-radius: 16px; box-sizing: border-box; transition: background-color 0.1s, border 0.1s; &::after { content: " "; position: absolute; top: 2px; left: 2px; width: @weuiSwitchHeight - 4; height: @weuiSwitchHeight - 4; border-radius: 15px; background-color: #fff; // 固定色值 box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.06); transition: transform 0.35s cubic-bezier(0.4, 0.4, 0.25, 1.35); } } .weui-switch:checked, .weui-switch-cp__input:checked + .weui-switch-cp__box, .weui-switch-cp__input[aria-checked="true"] + .weui-switch-cp__box { background-color: @weuiColorPrimary; &::after { transform: translateX(20px); } } .weui-switch[disabled], .weui-switch-cp__input[disabled] + .weui-switch-cp__box, .weui-switch-cp__input[aria-disabled="true"] + .weui-switch-cp__box { opacity: 0.1; } // 兼容小程序/IE Edge的版本 .weui-switch-cp__input { position: absolute; width: 0; height: 0; opacity: 0; overflow: hidden; } .weui-switch-cp__box { display: block; }