Back to Basic will answer some of my questions when I first started learning CSS. Personally, I think when you start learning CSS, it will be very ...
For further actions, you may consider blocking this person and/or reporting abuse
The one-line summary says it all! Nice examples to highlight the differences. I would like to quote from devopedia.org/css-grid-layout :
"CSS Grid doesn't replace Flexbox. Grid items can be flex parents and vice versa."
Thanks for your addition!
It does
Your example #2 (divide page into parts) won't work in Safari. There's no need to hack around with 100% width, there ape specific flexbox properties for that - flex-grow and/or flex-basis:
Also, this is actually the case when grid would be better / simpler / easier:
Thanks for your addition! I edited the post!
It turns out that using flex-basis won't work with images. But it is fine on other tags
Why not "grid-template-columns: 1fr 1fr"? This will produce the same right?
Correct, I usually use fraction unit too.
Will be nice if you explain what:
means.
One third? Nope. One column and three rows? nope. One ror and three columns? nope.
It is not intuitive to mw
I think a lot of people struggle with grid untill you realize that you are not positioning items in terms of colum- and row-areas, but instead lines.
Lets say we draw 3 colums. That gives us 4 vertical lines. So if the container needs to fill out the 3 AREAS you need to write:
grid-column: 1/4; This means that you start at line 1 and end at line 4.
Oh my god! Thank you.
That totally make it click for me.
Thanks
Your' welcome 😊👍
You can look it up at the link that I referred, after that with the numbering illustration I put up, it should be intuitive enough! Good luck 🚀
Nice article ...in short Use flex for one dimensionl group of things ie things that need to be placed in a row only, or things that need to be placed column only. ie nav bar = things in a row. With flex you cannot control both row and column.
Use CSS grid for 2 dimensional placement where you want to cotrol the row and column placements. ie the complex layouts of a website.
In flex box you can acheive many things that CSS grid can do, but you have to start nesting containers, which ends up over complicating.
Great recap!
Grid and Flex box actually goes well together, but grid is simpler and removes a lot of unnecessary code
Thank you!
*insert Thank you! meme
;)
Great article!
Note that the
gap
property can also be used to add spacing between your elements in a flexbox layout: caniuse.com/flexbox-gap.It is supported by all major browsers by now :-)
Thanks for your addition. Yep, finally ios & safari is supported, we can start using it now, no more
.flex > * + *
😬With those tiny bits of rows and columns? Wow, Grid says divide and conquer! Adjust in order to fit into any tiny bit of space available; Flexboxes even admit they would employ the services of a grid if necessary! Flexbox has the ability to line things up in one dimension (horizontal) but hey, grids with their rows and columns do the same in 2-dimensions! Rows x Columns.. capable of adjusting based on what's going into the grid.
I do everything with grid, it is less code and who cares about IE.
Nice! I think with
grid-auto-flow
it can easily replace flexbox now, it is also easier to understand grid than flexbox.Yes grid makes just more sense and you can picture it in your head
Great overview!
I love how the text in the "Divide page into parts" codepen is "Hello Bambang".
But personally, I found mix of Grid + Flexbox more customizable and handy than either of them alone.
Thanks for sharing! What's with grid in older browsers? I'm not about IE, rather about old Androids from like 2016 or 18
Hey, I don’t really know about old androids, but you can check compatibility on this website. On IE there are some features like the gap property that are not supported yet.
I love this, especially the case-by-case scenario made it much easier to visualize!
Thanks! I tried to summarize all the things such as illustrations, code examples that made me understand when I start learning this topic, and write this blog to help others out!
I'm not a css hardcore user, although I would prefer Flexbox, it's really flexible and easy when you get used to it.
I also love flexbox! Really powerful especially the
justify-content
property.Both…