Skip to content

Commit f632e2a

Browse files
committed
switch样式优化
1 parent 83ad136 commit f632e2a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/lib/Switch.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<template>
22
<button @click="toggle" :class="{checked:value}"> <span></span> </button>
3-
<div>{{ value }}</div>
43
</template>
54
<script lang="ts">
65
export default {
@@ -24,10 +23,9 @@ button{
2423
height: $h;
2524
width: $h*2;
2625
border: none;
27-
background: grey;
26+
background: #bfbfbf;
2827
border-radius: $h/2;
2928
position: relative;
30-
cursor: pointer;
3129
}
3230
span{
3331
position: absolute;
@@ -37,15 +35,21 @@ span{
3735
width: $h2;
3836
background:white;
3937
border-radius: $h2 / 2;
40-
transition: left 250ms;
38+
transition: all 250ms;
4139
}
4240
button.checked{
43-
background: #1989fa;
41+
background: #1890ff;
4442
}
4543
button.checked > span {
4644
left: calc(100% - #{$h2} - 2px);
4745
}
4846
button:focus{
4947
outline: none;
5048
}
49+
button:active{
50+
> span {width: $h2 + 4px;}
51+
}
52+
button.checked:active{
53+
> span {width: $h2 + 4px; margin-left: -4px;}
54+
}
5155
</style>

0 commit comments

Comments
 (0)