CSS animations make it possible to animate transitions from one CSS style to another.
@keyframes my-animation {
from {
background-color: red;
}
to {
background-color: yellow;
}
}
.animate {
animation: my-animation 4s infinite;
}
Transitions provide a way to control animation speed when changing CSS properties.
.transition {
transition: background-color 0.5s ease;
}
.transition:hover {
background-color: green;
}
Pseudo-classes are used to define the special state of an element.
/* Hover state */
a:hover {
color: red;
}
/* First child of a parent */
p:first-child {
font-weight: bold;
}
CSS variables, also known as custom properties, allow you to store reusable values.
:root {
--main-color: blue;
}
.element {
background-color: var(--main-color);
}
Responsive design aims to make websites look good on all devices.
/* Mobile-first approach */
@media only screen and (min-width: 600px) {
.container {
width: 80%;
}
}
Ready to dive deeper? Check out these free resources: