mirror of
https://github.com/uiverse-io/galaxy.git
synced 2025-11-28 05:00:22 +08:00
76 lines
1.8 KiB
HTML
76 lines
1.8 KiB
HTML
<div id="menuToggle">
|
|
<input id="checkbox" type="checkbox">
|
|
<label class="toggle" for="checkbox">
|
|
<div class="bar bar--top"></div>
|
|
<div class="bar bar--middle"></div>
|
|
<div class="bar bar--bottom"></div>
|
|
</label>
|
|
</div>
|
|
<style>
|
|
/* From Uiverse.io by vk-uiux - Tags: animation, switch, hamburger, toggle, css, click effect, toggle switch, css effect, click animation */
|
|
#checkbox {
|
|
display: none;
|
|
}
|
|
|
|
.toggle {
|
|
position: relative;
|
|
width: 40px;
|
|
cursor: pointer;
|
|
margin: auto;
|
|
display: block;
|
|
height: calc(4px * 3 + 11px * 2);
|
|
}
|
|
|
|
.bar {
|
|
position: absolute;
|
|
left: 0;
|
|
right: 0;
|
|
height: 4px;
|
|
border-radius: calc(4px / 2);
|
|
background: #7b52b9;
|
|
color: inherit;
|
|
opacity: 1;
|
|
transition: none 0.35s cubic-bezier(.5,-0.35,.35,1.5) 0s;
|
|
}
|
|
|
|
/***** Collapse Animation *****/
|
|
|
|
.bar--top {
|
|
bottom: calc(50% + 11px + 4px/ 2);
|
|
transition-property: bottom,margin,transform;
|
|
transition-delay: calc(0s + 0.35s),0s,0s;
|
|
}
|
|
|
|
.bar--middle {
|
|
top: calc(50% - 4px/ 2);
|
|
transition-property: top,opacity;
|
|
transition-duration: 0.35s,0s;
|
|
transition-delay: calc(0s + 0.35s * 1.3),calc(0s + 0.35s * 1.3);
|
|
}
|
|
|
|
.bar--bottom {
|
|
top: calc(50% + 11px + 4px/ 2);
|
|
transition-property: top,transform;
|
|
transition-delay: 0s;
|
|
}
|
|
|
|
#checkbox:checked + .toggle .bar--top {
|
|
bottom: calc(50% - 11px - 4px);
|
|
margin-bottom: calc(11px + 4px/ 2);
|
|
transform: rotate(45deg);
|
|
transition-delay: calc(0s + 0.35s * .3),calc(0s + 0.35s * 1.3),calc(0s + 0.35s * 1.3);
|
|
}
|
|
|
|
#checkbox:checked + .toggle .bar--middle {
|
|
top: calc(50% + 11px);
|
|
opacity: 0;
|
|
transition-duration: 0.35s,0s;
|
|
transition-delay: 0s,calc(0s + 0.35s);
|
|
}
|
|
|
|
#checkbox:checked + .toggle .bar--bottom {
|
|
top: calc(50% - 4px/ 2);
|
|
transform: rotate(-45deg);
|
|
transition-delay: calc(0s + 0.35s * 1.3),calc(0s + 0.35s * 1.3);
|
|
}
|
|
</style>
|