W3C home > Mailing lists > Public > www-style@w3.org > May 2013

RE: [css-grid-layout] Relationship with Flexbox

From: François REMY <francois.remy.dev@outlook.com>
Date: Mon, 6 May 2013 19:07:50 +0200
Message-ID: <DUB120-W402CC4ADF97B5FFEF4ABA3A5B90@phx.gbl>
To: İime Vidas <sime.vidas@gmail.com>, "www-style@w3.org" <www-style@w3.org>
> Could someone provide a quick comparison in simple terms? When would a 
> web developer use Grid Layout vs Flexbox? 
> 
> -- @simevidas

CSS Flexbox is more advanced toward the implementation path than CSS Grid. So, in the short term, CSS Flexbox would be your best option whatever the use case (execpt maybe display: table in some cases).

This put aside, CSS Grid can be seen as a superset of CSS Flexbox: it gives you much more freedom in the way you layout elements (and this is even more true with the new line-naming model). For example, you can mix a fixed amount of specialized columns while using a variable amount of repeated columns, depending on the browser's rendering area size.


As a basic rule of thumb, use Flexbox if you have one type of item to align and can define rougly define the alignement as a justified flow of inline-block elements, like this: 

   A  B  C

or

   AAAAA
   
   BBBBB
   
   CCCCC

or

   A B C
   D E F
   G H


If you need something more complex (for example, you may want to reorder elements from the left column of your blog on small screens:

   hhhhh
   mcccc
   mcccc
   mcccc

into

   hhm
   ccc
   ccc


Best regards,
François 		 	   		  
Received on Monday, 6 May 2013 17:08:17 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:11 UTC