Hello I am creating a webpage and want to create a on off switch, which switches my website from english to german. to illustrate that better i want the switch to change from the english flag to the german flag (optionally: with a 180 degree spin). my code is as following:
<label class="switch">
<input type="checkbox">
<span class="slider round"></span>
<div class="background"></div>
</label>
/* The switch - the box around the slider */
.switch {
position: relative;
display: inline-block;
width: 42px;
height: 23.8px;
}
/* Hide default HTML checkbox */
.switch input {
opacity: 0;
width: 0;
height: 0;
}
/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 18.2px;
width: 18.2px;
left: 3px;
bottom: 3px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #FF5733;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(18.2px);
-ms-transform: translateX(18.2px);
transform: translateX(18.2px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
i tried using svg and adjusting them via css. because of that transitions like .slider: before or input: checked couldnt work anymore. also even if they did work they wouldnt be user friendly…
Hold my Vodka Cyka is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.