switch滑動切換按鈕樣式
阿新 • • 發佈:2018-11-26
<input class="mui-switch mui-switch-animbg" ng-checked="checked==true" ng-click="switchTab()" type="checkbox">
.mui-switch { width: 40px; height: 20px; position: relative; border: 1px solid #dfdfdf; background-color: #fdfdfd; box-shadow: #dfdfdf 0 0 0 0 inset; border-radius: 20px; /* background-clip: content-box; */ display: inline-block; -webkit-appearance: none; user-select: none; outline: none; } .mui-switch:before { content: ''; width: 19px; height: 19px; position: absolute; top: 0px; left: 0; border-radius: 20px; background-color: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); } .mui-switch:checked { border-color: #fd5454; box-shadow: #fd5454 0 0 0 16px inset; background-color: #fd5454; } .mui-switch:checked:before { left: 19px; } .mui-switch.mui-switch-animbg { transition: background-color ease 0.4s; } .mui-switch.mui-switch-animbg:before { transition: left 0.3s; } .mui-switch.mui-switch-animbg:checked { box-shadow: #fd5454 0 0 0 0 inset; background-color: #fd5454; transition: border-color 0.4s, background-color ease 0.4s; }
$scope.checked = false
$scope.switchTab = function (){
$scope.checked = !$scope.checked
}