Grid / Flex solution

Hi frontenders, how would you solve this? 😁
No description
8 Replies
MarkBoots
MarkBoots14mo ago
grid is ideal for this, 2 columns, 3 rows and a gap. 1st and 3rd image row span of 2 something like this https://codepen.io/MarkBoots/pen/MWZzbGj (first try yourself)
impactftw
impactftwOP14mo ago
Thanks Markboots 😉 its not really the same because the left bottom image has a different size instead the right top😄 But its close 😊😉
MarkBoots
MarkBoots14mo ago
well you can change the grid-column rows
impactftw
impactftwOP14mo ago
Is it also possible to use %? So that i have the correct ratio?
Zoë
Zoë14mo ago
Use fr instead and you can use it as a drop in replacement for % if you want (It just doesn’t have to add up to 100. You can do 66.6fr 33.3fr or just 2fr 1fr)
impactftw
impactftwOP14mo ago
Ok! Then I need to use grid-auto-rows: auto? Instead of grid-template-rows: repeat(12, 87px);
Jochem
Jochem14mo ago
where's repeat(12, 87px) coming from? Unless you actually need 12 cells and they have to be 87px exactly, that's terrible practice Take Mark's example, this line:
grid-template-rows: 1fr 0.25fr 1fr;
grid-template-rows: 1fr 0.25fr 1fr;
You can adjust those values until the rows match the heights you want to have. That 0.25fr is the height of the overlap, the first 1fr is the height of the top-right image (because it's the image that's only in the first row), the second 1fr determines the height of the bottom left image Like Z said, 1fr is a relative unit. All the values are added up, then the available space is distributed according to how many fr each row or column is defined as. 1fr 2fr 1fr is the same as 2fr 4fr 2fr, both result in a middle row/column that's twice the size of the other two
Zoë
Zoë14mo ago
For completeness here's the code https://codepen.io/z-/pen/NWeELdy/e428c64bebab12246ed9542f7019af6e (if you want to see plain HTML or CSS click the v down chevron and click "View Compiled")
Want results from more Discord servers?
Add your server