Design comparison
Solution retrospective
2nd challenge on this website. Used Flexbox to align the items. Any feedback will be appreciated.
Also, I can't find a solution to get my flex items to grow at the same time. When the window expands, one item becomes bigger than the others. Any suggestions on how to solve this issue is much appreciated. Thanks!
Community feedback
- @grizhlieCodesPosted over 3 years ago
Howdy Sam.
Keep the solutions coming 😁
Edit: When potentially applying the below solutions take your time and play around with the code a bit so they make sense. I usually open up codepen or something and just make some simple mockups to ensure I understand the underlying concepts 👍
I had a look and I have some brief pointers, might add to this a bit later if i get a moment.
- In your css add:
:root, * { box-sizing: border-box; }
This simply is more intuitive behaviour where sizing is concerned. It includes any margin/padding into the elements calculated width and height. This link should clear it up.
This will already improve some sizing issues I noticed.
-
Add
flex: 1 0 200px
to your.item
class. This is a shorthand forflex: flex-grow flex-shrink flex-basis
. All 3 are worth understanding so have a look and take your time. But you should see that your content will immediately look closer to what you'd expect. -
For your
.container
you can removejustify-content
andalign-items
. These are only needed if your flex-parent is bigger than the content. In your projects case it is not, as the content is dictating the height. -
For your
.container
update the width property a bit:
.container { /* other code */ max-width: 920px; }
This is just a simple way of accomplishing that without adding actual margin/padding. Of course do with sizing as you see fit.
- Remove
align-self
from.item
.
Hope that helps, if you have any questions to the above just ask and I'll reply on a break!
Marked as helpful0 - @suansenPosted over 3 years ago
Hi Rafal, Awesome stuff! thanks so much for the helpful and detailed feedback. I've improved the code per your suggestion and it's working as per expected now. I'll update the solution soon.
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