Modern CSS Layouts: You Might Not Need A Framework For That<\/h1>\nBrecht De Ruyte<\/address>\n 2024-05-22T15:00:00+00:00
\n 2025-03-19T12:04:52+00:00
\n <\/header>\n
Establishing layouts in CSS is something that we, as developers, often delegate to whatever framework we\u2019re most comfortable using. And even though it\u2019s possible to configure a framework to get just what we need out of it, how often have you integrated an entire CSS library simply for its layout features? I\u2019m sure many of us have done it at some point, dating back to the days of 960.gs, Bootstrap, Susy, and Foundation.<\/p>\n
Modern CSS features have significantly cut the need to reach for a framework simply for its layout. Yet, I continue to see it happen. Or, I empathize with many of my colleagues who find themselves re-creating the same Grid or Flexbox layout over and over again.<\/p>\n
In this article, we will gain greater control over web layouts. Specifically, we will create four CSS classes that you will be able to take and use immediately on just about any project or place where you need a particular layout that can be configured to your needs.<\/strong><\/p>\nWhile the concepts we cover are key, the real thing I want you to take away from this is the confidence to use CSS for those things we tend to avoid doing ourselves<\/strong>. Layouts used<\/em> to be a challenge on the same level of styling form controls. Certain creative layouts may still be difficult to pull off, but the way CSS is designed today solves the burdens of the established layout patterns we\u2019ve been outsourcing and re-creating for many years.<\/p>\nWhat We\u2019re Making<\/h2>\n
We\u2019re going to establish four CSS classes, each with a different layout approach. The idea is that if you need, say, a fluid layout based on Flexbox, you have it ready. The same goes for the three other classes we\u2019re making.<\/p>\n
And what exactly are these classes? Two of them are Flexbox layouts, and the other two are Grid layouts, each for a specific purpose. We\u2019ll even extend the Grid layouts to leverage CSS Subgrid for when that\u2019s needed.<\/p>\n
Within those two groups of Flexbox and Grid layouts are two utility classes: one that auto-fills the available space \u2014 we\u2019re calling these \u201cfluid\u201d layouts<\/strong> \u2014 and another where we have greater control over the columns and rows \u2014 we\u2019re calling these \u201crepeating\u201d layouts<\/strong>.<\/p>\nFinally, we\u2019ll integrate CSS Container Queries so that these layouts respond to their own size for responsive behavior rather than the size of the viewport. Where we\u2019ll start, though, is organizing our work into Cascade Layers, which further allow you to control the level of specificity and prevent style conflicts with your own CSS.<\/p>\n
\n
\n 2025-03-19T12:04:52+00:00
\n <\/header>\n
While the concepts we cover are key, the real thing I want you to take away from this is the confidence to use CSS for those things we tend to avoid doing ourselves<\/strong>. Layouts used<\/em> to be a challenge on the same level of styling form controls. Certain creative layouts may still be difficult to pull off, but the way CSS is designed today solves the burdens of the established layout patterns we\u2019ve been outsourcing and re-creating for many years.<\/p>\n We\u2019re going to establish four CSS classes, each with a different layout approach. The idea is that if you need, say, a fluid layout based on Flexbox, you have it ready. The same goes for the three other classes we\u2019re making.<\/p>\n And what exactly are these classes? Two of them are Flexbox layouts, and the other two are Grid layouts, each for a specific purpose. We\u2019ll even extend the Grid layouts to leverage CSS Subgrid for when that\u2019s needed.<\/p>\n Within those two groups of Flexbox and Grid layouts are two utility classes: one that auto-fills the available space \u2014 we\u2019re calling these \u201cfluid\u201d layouts<\/strong> \u2014 and another where we have greater control over the columns and rows \u2014 we\u2019re calling these \u201crepeating\u201d layouts<\/strong>.<\/p>\n Finally, we\u2019ll integrate CSS Container Queries so that these layouts respond to their own size for responsive behavior rather than the size of the viewport. Where we\u2019ll start, though, is organizing our work into Cascade Layers, which further allow you to control the level of specificity and prevent style conflicts with your own CSS.<\/p>\nWhat We\u2019re Making<\/h2>\n