<label for="stoggle" class="wtoggle skew">
<input class="wtoggle__input" type="checkbox" id="stoggle">
<div class="wtoggle__fill"></div>
</label>
.wtoggle.skew {
--width: 70px;
--height: calc(var(--width) / 2);
display: inline-block;
cursor: pointer;
transform: skew(-10deg);
}
.wtoggle__input {
display: none;
}
.wtoggle__fill {
display: flex;
align-items: center;
justify-content: center;
font-size: 1rem;
font-weight: bold;
font-family: sans-serif;
position: relative;
width: var(--width);
height: var(--height);
color: #FFFFFF;
background: #888888;
transition: all 0.5s ease;
}
.wtoggle__input:checked ~ .wtoggle__fill {
background: #2271B1;
overflow: hidden;
}
.wtoggle__fill::before {
content: "OFF";
transition: all 0.2s ease;
width: 100%;
text-align: center;
position: absolute;
line-height: 2em;
font-weight: bold;
color: #fff;
}
.wtoggle__fill::after {
content: "ON";
transition: all 0.2s ease;
width: 100%;
text-align: center;
position: absolute;
line-height: 2em;
font-weight: bold;
color: #fff;
transform: translate(100%);
}
.wtoggle__input:checked ~ .wtoggle__fill::after {
transform: translate(0%);
}
.wtoggle__input:checked ~ .wtoggle__fill::before {
transform: translate(-100%);
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.