How to achieve this style

I want to create an style like in the picture, should i use grid or flex? how?
No description
6 Replies
vince
vince3mo ago
I'd personally use flex. Flex parent container. Each column is another flex container. n + 1 / odd child containers in parent flex container have a margin top. Use media queries to adjust for mobile (or desktop if mobile first)
EIO
EIO3mo ago
I agree with @vince, however, I really love grid for this. Here's a Pen of how I achieved it with grid: https://codepen.io/eioluseyi/pen/GRaKpRq It's responsive, so you can shriink the view to test it.
Rägnar O'ock
Rägnar O'ock3mo ago
That wouldn't work with the mobile view shown on the right A grid for the layout and a translateY on every odd elements in a media query for "desktop" would work tho And it would require less markup
vince
vince3mo ago
Ohhh I see now
Lloyd Peterson
Lloyd Peterson3mo ago
thank you @vince , @EIO and @Rägnar for your help, Aprreciated! I already achieve the style.
ZNP
ZNP3mo ago
If you wanna see my version here it is: https://codepen.io/Ziphour/pen/VwOZbJZ
Z
CodePen
VwOZbJZ
...