CSS animations are great for stuff like 'hover' and a little embellishment here or there.
You can also kinda hack some stuff together that feels like interaction with check boxes and things,
but - when you need real 'click' events and functionality - that's what JavaScript is for.
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
console.clear();
var toggleBody = document.querySelector('.toggle-body');
toggleBody.addEventListener('click', function() {
document.body.classList.toggle('toggled');
});
body {
background-color: yellow;
transition: 1s;
}
body button {
transition: 2s;
}
body.toggled {
background-color: orange;
}
body.toggled button {
transform: translate(20px, 20px);
}
<button class='toggle-body'>Toggle body color</button>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…