Hi there,
I have this html and css code(did not make it) that is a animated switch. I’d like the switch, once activated and the switch moves down (click release) to take me to another page.
I’m not sure how to do this in the HTML?
The new page would open in target=" _blank";
I’m learning and playing with HTML, CSS and JS.
<div class="switchbox">
<label class="switch">
< input class="chk" type="checkbox">
<span class="slider"></span>
</label>
</div>
/* The switch - the box around the slider */
.switch {
font-size: 17px;
position: relative;
display: inline-block;
width: 1.2em;
height: 3.3em;
}
/* Hide default HTML checkbox */
.switch .chk {
opacity: 0;
width: 0;
height: 0;
}
/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgb(230, 0, 0);
transition: .4s;
border-radius: 5px;
}
.slider:before {
position: absolute;
content: "";
height: .5em;
width: 2.4em;
border-radius: 5px;
left: -0.6em;
top: 0.2em;
background-color: rgb(68, 66, 66);
box-shadow: 0 6px 7px rgba(0,0,0,0.3);
transition: .4s;
}
.slider:before, .slider:after {
content: "";
display: block;
}
.slider:after {
background: linear-gradient(transparent 50%, rgba(255, 255, 255, 0.15) 0) 0 50% / 50% 100%,
repeating-linear-gradient(90deg,rgb(78, 78, 78) 0,rgb(141, 135, 135),rgb(97, 96, 96) 20%,rgb(97, 95, 95) 20%,rgb(99, 99, 99) 40%) 0 50% / 50% 100%,
radial-gradient(circle at 50% 50%,rgb(95, 94, 94) 25%, transparent 26%);
background-repeat: no-repeat;
border: 0.25em solid transparent;
border-left: 0.4em solid #464646;
border-right: 0 solid transparent;
transition: border-left-color 0.1s 0.3s ease-out, transform 0.3s ease-out;
transform: translateX(-22.5%) rotate(90deg);
transform-origin: 25% 50%;
position: relative;
top: 0.5em;
left: 0.55em;
width: 2em;
height: 1em;
box-sizing: border-box;
}
.chk:checked + .slider {
background-color: limegreen;
}
.chk:focus + .slider {
box-shadow: 0 0 1px limegreen;
}
.chk:checked + .slider:before {
transform: translateY(2.3em);
}
.chk:checked + .slider:after {
transform: rotateZ(90deg) rotateY(180deg) translateY(0.45em) translateX(-1.4em);
}