REST Countries API with React Router and CSS Grid
Design comparison
Solution retrospective
I made the country results container with CSS Grid. I gave the property align-items: flex-start to the card because some country flags have different dimensions, so this created different height cards for each card in the row. I wanted to respect the dimensions of each country's flag. One solution would be to set a fixed height to flags in the country card, but then that would shrink taller country flags and put whitespace on either side of those flags.
.container__results { display: grid; grid-template-columns: 1fr; gap: 2em; align-items: flex-start; } @media (min-width: 30rem) { .container__results { grid-template-columns: repeat(2, 1fr); gap: 3em; } } @media (min-width: 55rem) { .container__results { grid-template-columns: repeat(3, 1fr); gap: 4em; } } @media (min-width: 90rem) { .container__results { grid-template-columns: repeat(4, 1fr); gap: 5em; } }
Community feedback
- @lipe11Posted over 2 years ago1@chowjiamingPosted over 2 years ago
@lipe11 thanks Luis! I have actually never heard of that CSS property before. However that would squish some country flags that are longer than they are tall. Granted, that's only a few flags. https://imgur.com/a/fglbp6Q
0@lipe11Posted over 2 years ago@chowjiaming I see what you mean! I wasn't aware some flags would be so distorted, thanks for pointing that out!.
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord