mirror of
https://github.com/uiverse-io/galaxy.git
synced 2025-11-27 20:50:21 +08:00
110 lines
No EOL
2.4 KiB
HTML
110 lines
No EOL
2.4 KiB
HTML
<div class="checkbox">
|
|
<input class="tgl" id="toggle" type="checkbox" />
|
|
<label class="tgl-btn" for="toggle"></label>
|
|
</div>
|
|
|
|
<style>
|
|
/* From Uiverse.io by elijahgummer - Tags: simple, animation, blue, switch, transition, click effect, click animation */
|
|
.checkbox {
|
|
--blue: #0d7eff;
|
|
--g08: #e1e5eb;
|
|
--g04: #848ea1;
|
|
text-align: center;
|
|
}
|
|
|
|
.checkbox .tgl {
|
|
display: none;
|
|
}
|
|
.checkbox .tgl,
|
|
.checkbox .tgl:after,
|
|
.checkbox .tgl:before,
|
|
.checkbox .tgl *,
|
|
.checkbox .tgl *:after,
|
|
.checkbox .tgl *:before,
|
|
.checkbox .tgl + .tgl-btn {
|
|
box-sizing: border-box;
|
|
}
|
|
.checkbox .tgl::selection,
|
|
.checkbox .tgl:after::selection,
|
|
.checkbox .tgl:before::selection,
|
|
.checkbox .tgl *::selection,
|
|
.checkbox .tgl *:after::selection,
|
|
.checkbox .tgl *:before::selection,
|
|
.checkbox .tgl + .tgl-btn::selection {
|
|
background: none;
|
|
}
|
|
.checkbox .tgl + .tgl-btn {
|
|
outline: 0;
|
|
display: block;
|
|
width: 57px;
|
|
height: 27px;
|
|
position: relative;
|
|
cursor: pointer;
|
|
user-select: none;
|
|
font-size: 12px;
|
|
font-weight: 400;
|
|
color: #fff;
|
|
}
|
|
.checkbox .tgl + .tgl-btn:after,
|
|
.checkbox .tgl + .tgl-btn:before {
|
|
position: relative;
|
|
display: block;
|
|
content: "";
|
|
width: 44%;
|
|
height: 100%;
|
|
}
|
|
.checkbox .tgl + .tgl-btn:after {
|
|
left: 0;
|
|
}
|
|
.checkbox .tgl + .tgl-btn:before {
|
|
display: inline;
|
|
position: absolute;
|
|
top: 7px;
|
|
}
|
|
.checkbox .tgl:checked + .tgl-btn:after {
|
|
left: 56.5%;
|
|
}
|
|
|
|
.checkbox .tgl + .tgl-btn {
|
|
background: var(--g08);
|
|
border-radius: 20rem;
|
|
padding: 2px;
|
|
transition: all 0.4s ease;
|
|
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
|
|
}
|
|
.checkbox .tgl + .tgl-btn:after {
|
|
border-radius: 2em;
|
|
background: #fff;
|
|
transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
|
|
padding 0.3s ease, margin 0.3s ease;
|
|
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
|
|
}
|
|
.checkbox .tgl + .tgl-btn:before {
|
|
content: "No";
|
|
left: 28px;
|
|
color: var(--g04);
|
|
transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
|
}
|
|
.checkbox .tgl + .tgl-btn:active {
|
|
box-shadow: inset 0 0 0 30px rgba(0, 0, 0, 0.1);
|
|
}
|
|
.checkbox .tgl + .tgl-btn:active:after {
|
|
padding-right: 0.4em;
|
|
}
|
|
.checkbox .tgl:checked + .tgl-btn {
|
|
background: var(--blue);
|
|
}
|
|
.checkbox .tgl:checked + .tgl-btn:active {
|
|
box-shadow: inset 0 0 0 30px rgba(0, 0, 0, 0.1);
|
|
}
|
|
.checkbox .tgl:checked + .tgl-btn:active:after {
|
|
margin-left: -0.4em;
|
|
}
|
|
.checkbox .tgl:checked + .tgl-btn:before {
|
|
content: "Yes";
|
|
left: 4px;
|
|
color: #fff;
|
|
}
|
|
|
|
</style>
|
|
|