mirror of
https://github.com/uiverse-io/galaxy.git
synced 2025-11-28 05:00:22 +08:00
124 lines
2.5 KiB
HTML
124 lines
2.5 KiB
HTML
<label class="switch">
|
|
<input type="checkbox" class="cb">
|
|
<span class="toggle">
|
|
<span class="left">off</span>
|
|
<span class="right">on</span>
|
|
</span>
|
|
</label>
|
|
<style>
|
|
/* From Uiverse.io by r7chardgh - Tags: switch, toggle switch, on/off */
|
|
/* The switch - the box around the slider */
|
|
.switch {
|
|
font-size: 17px;
|
|
position: relative;
|
|
display: inline-block;
|
|
width: 5em;
|
|
height: 2.5em;
|
|
}
|
|
|
|
/* Hide default HTML checkbox */
|
|
.switch .cb {
|
|
opacity: 0;
|
|
width: 0;
|
|
height: 0;
|
|
}
|
|
|
|
/* The slider */
|
|
.toggle {
|
|
position: absolute;
|
|
cursor: pointer;
|
|
width: 100%;
|
|
height: 100%;
|
|
background-color: #373737;
|
|
border-radius: .1em;
|
|
transition: .4s;
|
|
text-transform: uppercase;
|
|
font-weight: 700;
|
|
overflow: hidden;
|
|
box-shadow: -.3em 0 0 0 #373737,-.3em .3em 0 0 #373737,.3em 0 0 0 #373737,.3em .3em 0 0 #373737,0 .3em 0 0 #373737;
|
|
}
|
|
|
|
.toggle > .left {
|
|
position: absolute;
|
|
display: flex;
|
|
width: 50%;
|
|
height: 88%;
|
|
background-color: #f3f3f3;
|
|
color: #373737;
|
|
left: 0;
|
|
bottom: 0;
|
|
align-items: center;
|
|
justify-content: center;
|
|
transform-origin: right;
|
|
transform: rotateX(10deg);
|
|
transform-style: preserve-3d;
|
|
transition: all 150ms;
|
|
}
|
|
|
|
.left::before {
|
|
position: absolute;
|
|
content: "";
|
|
width: 100%;
|
|
height: 100%;
|
|
background-color: rgb(206, 206, 206);
|
|
transform-origin: center left;
|
|
transform: rotateY(90deg);
|
|
}
|
|
|
|
.left::after {
|
|
position: absolute;
|
|
content: "";
|
|
width: 100%;
|
|
height: 100%;
|
|
background-color: rgb(112, 112, 112);
|
|
transform-origin: center bottom;
|
|
transform: rotateX(90deg);
|
|
}
|
|
|
|
.toggle > .right {
|
|
position: absolute;
|
|
display: flex;
|
|
width: 50%;
|
|
height: 88%;
|
|
background-color: #f3f3f3;
|
|
color: rgb(206, 206, 206);
|
|
right: 1px;
|
|
bottom: 0;
|
|
align-items: center;
|
|
justify-content: center;
|
|
transform-origin: left;
|
|
transform: rotateX(10deg) rotateY(-45deg);
|
|
transform-style: preserve-3d;
|
|
transition: all 150ms;
|
|
}
|
|
|
|
.right::before {
|
|
position: absolute;
|
|
content: "";
|
|
width: 100%;
|
|
height: 100%;
|
|
background-color: rgb(206, 206, 206);
|
|
transform-origin: center right;
|
|
transform: rotateY(-90deg);
|
|
}
|
|
|
|
.right::after {
|
|
position: absolute;
|
|
content: "";
|
|
width: 100%;
|
|
height: 100%;
|
|
background-color: rgb(112, 112, 112);
|
|
transform-origin: center bottom;
|
|
transform: rotateX(90deg);
|
|
}
|
|
|
|
.switch input:checked + .toggle > .left {
|
|
transform: rotateX(10deg) rotateY(45deg);
|
|
color: rgb(206, 206, 206);
|
|
}
|
|
|
|
.switch input:checked + .toggle > .right {
|
|
transform: rotateX(10deg) rotateY(0deg);
|
|
color: #487bdb;
|
|
}
|
|
</style>
|