1 minute read · CSS
Writing CSS that scales is one of the hardest challenges in frontend development. Let's explore modern techniques that will keep your stylesheets maintainable.
CSS Custom Properties (Variables)
The foundation of a scalable design system:
:root {
--color-primary-500: hsl(220, 90%, 55%);
--text-base: 1rem;
--space-4: 1rem;
--duration-normal: 300ms;
--easing-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}Container Queries
Finally, style components based on their container:
.card-container {
container-type: inline-size;
container-name: card;
}
@container card (min-width: 500px) {
.card {
display: grid;
grid-template-columns: 200px 1fr;
}
}Modern Layout with CSS Grid
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: var(--space-6);
}Scroll-Driven Animations
Animate elements based on scroll position without JavaScript:
@keyframes reveal {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
.animated-section {
animation: reveal linear both;
animation-timeline: view();
animation-range: entry 0% entry 25%;
}Conclusion
Modern CSS is incredibly powerful. By leveraging custom properties, container queries, and new selectors, you can build design systems that are flexible, maintainable, and future-proof.