DEV Community

Cover image for 
Do CSS Grid replace Flexbox?
Nava
Nava

Posted on

3 2

Do CSS Grid replace Flexbox?

Grid is better than flexbox for a number of valid points. There are things grid do better than flexbox and vice versa.On March 2017 with less browser support than flexbox grid was released unprefixed and ready-to-go, in Chrome, Opera, Firefox, and Safari.
Grid is better for whole page layouts than flexbox because using flexbox for layout can cause content shift during loading due to js modifying the DOM which can be used for tools not rules.

Grid can add columns or rows on fly with grid-template-rows or grid-template-columns and use grid-gap property to make home made style page. The flexbox on other hand use its content to layout the page using flex-wrap and flex-basis which can essentially implement flex-grow or flex-shrink the boxes.

Furthermore, Grid uses the auto layout, minmax(), repeat(), and auto-fill which can provide responsive media query alternative.
Flexbox is essentially for laying out items in a single dimension – in a row OR a column. Grid is for layout of items in two dimensions – rows AND columns.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more