Changing the ui state without using js

 Lets say you have a button which sets the dark mode, how do you react to the change without using js ?



<!DOCTYPE html>
<html lang="en">
<style>
.trigger:checked + .area {
background-color: red;
}

.area {
height: 300px;
width: 300px;
background-color: black;
}
</style>
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>


<input type="checkbox" class="trigger" />
<div class="area">
</div>
</html>

The above code does the same. It uses the :checked state to modify the other classes.

Share:

0 comments:

Post a Comment