Urgent.News

What's breaking now, across thousands of outlets.

Tech

10 CSS Layouts Every Developer Should Know (Grid & Flexbox Explained the Simple Way)

You've seen these layouts a hundred times, blogs, dashboards, Pinterest boards, magazine sites. But when you sit down in front of a design file, do you know which CSS tool to reach for, or are you just guessing until something sticks? In this post I'm breaking down 10 of the most common web layouts, and for each one I'm answering the question that actually matters: why this tool and not the other…

Every developer should be familiar with these 10 common CSS layouts: grid and flexbox. Flexbox works in one direction, arranging items in a single row or column. Grid operates in two directions, managing both rows and columns simultaneously. Understanding these two tools is essential for creating layouts without relying on guesswork.

1. The Two-Column Layout is a common design element found in SaaS dashboards and documentation sites. This layout uses Grid to arrange a sidebar alongside the main content area. The CSS for this layout specifies a grid with two columns: one fixed width for the sidebar and the other taking up the remaining space. A gap of 24 pixels is added between the columns, and the container is given a minimum height to fill the viewport.

2. Split Screen layouts are simple halves, like login and sign-up pages. Using Grid, a page can be divided into two equal columns. Flexbox centers the content within each column, providing a clean and centered appearance for the content.

3. Asymmetrical layouts can be tricky for beginners. With Grid, one box can be made to span multiple columns and rows, creating a large focal point surrounded by smaller boxes. This layout technique can help create visually interesting and engaging designs.

4. The F-Shape Layout mimics the way users tend to scan a page - from left to right across the top, then down the left side, and back across. By using Grid's grid-template-areas feature, developers can quickly create this layout without writing complex code. This feature allows for a clear and intuitive way of defining the layout structure.

5. The Z-Shape (or Zig-Zag) layout is often used in landing pages to guide the user's eye across the page. Flexbox is used to arrange items in a single row, with a class allowing for easy reversal of the direction. This technique is useful for keeping the user engaged and focused on the page content.

6. Card Grid layouts are popular for product listings, blog previews, and photo galleries. With Grid, developers can create a responsive grid of cards that adapt to the available space. By using a combination of Grid's auto-fit and minmax() functions, columns can be created that automatically adjust to fit the available width, eliminating the need for multiple media queries.

7. The Featured Media Layout features a prominent image or video on one side, with supporting text on the other. By using Grid, developers can control the visual hierarchy of the layout by assigning different column ratios. This allows the featured media to stand out while still providing a clear and balanced layout.

8. Masonry Layouts, like those seen on Pinterest, create a visually appealing staggered layout for images or content blocks. While CSS Multi-Column can create a grid-like structure, it is more commonly used for equal-height columns. For a true masonry layout, developers often turn to JavaScript libraries. However, Grid's flexibility and simplicity make it a solid alternative for creating these layouts without sacrificing performance.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Letter to Friday-Me: Budget, Isolate, Then Stamp the Receipt

The following letter is a reconstructed failure log. It is not a claim about any employer. Friday at 16:40, the coding agent was still looping. No receipt named the runner, files, or stop condition.

  • Coding agent looped without a hard stop, consuming a full workday
  • Remote workspace inherited local dirt, causing unrelated diffs
  • No receipt provided for the loop's actions, hindering debugging

Your Free Probe Passed. You Still Measured the Wrong Box

Your free probe passed on a scratch box. That green badge still measured the wrong machine. A green free endpoint is a cheap probe. It is not a production ship gate.

  • Green free endpoint is cheap probe, not production ship gate
  • Eval-transfer bug causes wrong machine measured in harness
  • Pin frozen identity, avoid replay confusion across endpoints

The Hidden SEO Cost of E-Commerce Filters

Filters are essential to e-commerce. They're also one of the easiest ways to create thousands of URLs nobody intentionally planned.

  • E-commerce filters create thousands of crawlable URLs, posing SEO challenges.
  • 10 brands, 8 colors, 5 sizes, and 6 price ranges generate massive URL space.
  • SEO decision should focus on whether URL represents actual user search intent.

More from Sunday 13 September →