index.vue
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<template>
<div class="md:hidden block">
<input ref="checkboxRef" id="checkbox" type="checkbox" />
<label class="toggle" for="checkbox" @click="drawer = !drawer">
<div id="bar1" class="bars"></div>
<div id="bar2" class="bars"></div>
<div id="bar3" class="bars"></div>
</label>
</div>
<el-drawer
v-model="drawer"
:with-header="false"
direction="ltr"
:append-to-body="true"
:lock-scroll="true"
size="266"
custom-class="drawer-sidebar"
@close="onClose"
>
<AppSidebar />
</el-drawer>
</template>
<script setup>
const drawer = ref(false);
const checkboxRef = ref(null);
// 关闭弹出框
function onClose() {
checkboxRef.value.checked = false;
drawer.value = false;
}
onMounted(() => {
// 获取复选框元素
checkboxRef.value = document.getElementById("checkbox");
});
</script>
<style scoped>
/* From Uiverse.io by Yaya12085 */
#checkbox {
display: none;
}
.toggle {
position: relative;
width: 35px;
height: 35px;
cursor: pointer;
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
gap: 10px;
transition-duration: 0.5s;
}
.bars {
width: 100%;
height: 4px;
background-color: rgb(92, 130, 255);
border-radius: 4px;
}
#bar2 {
transition-duration: 0.8s;
}
#bar1 {
width: 50%;
}
#bar2 {
width: 75%;
}
#checkbox:checked + .toggle .bars {
position: absolute;
transition-duration: 0.5s;
}
#checkbox:checked + .toggle #bar2 {
transform: scaleX(0);
transition-duration: 0.1s;
}
#checkbox:checked + .toggle #bar1 {
width: 100%;
transform: rotate(45deg);
transition-duration: 0.5s;
}
#checkbox:checked + .toggle #bar3 {
width: 100%;
transform: rotate(-45deg);
transition-duration: 0.5s;
}
#checkbox:checked + .toggle {
transition-duration: 0.5s;
transform: rotate(180deg);
}
</style>