I have an exam at uni soon and my web design professor asked us to create a website.
In this website we need to apply a style change, switching between 2 different css stylesheets.
I thought about doing a black and white version by default and then, with a toggle switch button, passing to a colored version.
I created the button but I can't understand how to link and transition from one stylesheet to another. I imagine I need to use Javascript but I don't know what to do. This my html part for the button:
.switch {
position: relative;
height: 34px;
width: 60px;
display: inline-block;
}
.switch input {
display: none;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
bottom: 0;
right: 0;
background-color: white;
border-radius: 26px;
transition: 0,4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
border-radius: 50%;
background-color: black;
left: 4px;
top: 4px;
transition: 0.4s;
}
input:checked + .slider {
background-color: #fffe54;
}
input:checked + .slider:before {
transform: translateX(26px);
}
<label class="switch">
<input type="checkbox">
<span class="slider"></span>
</label>
If someone can help me it will be much appreciated!