Design comparison
Solution retrospective
4/5/2021 update:
- 167160d 2021-04-06 | fix: removed the flex shrink on rating__stars to prevent the stars from wrapping (HEAD -> master, origin/master)
- 056d2a1 2021-04-06 | fix: changed justify-content from end to flex-end for better compatibility (chrome)
- 7ce075f 2021-04-06 | fix: restored margin-left to ratings layout
- b738a17 2021-04-05 | fix: was using backquote instead of blockquote
4/4/2021: This was a fun one where I made liberal use of flex containers as a way of dynamically spacing out the components.
Like the ratings section for example. Initially I was practicing a for loop on it and made it such that margin-left = 16px * (x - 1) where x is each rating component. So the first one would have margin-left of 0, the 2nd would have 16px, the 3rd would have 32px.
Which works better for future proofing if additional components were to be added. But I decided to make them flex and assume that only 3 items are used, so the top one got justify-content of start, the 2nd one center, and the 3rd one end with the extra space being shrunk dynamically as the viewport shrunk. And I really liked how that turned out along with how the other flex containers shrink. It was mostly done through flex: 0 1 <basis> which prevented them from growing, but allowed them to shrink once the viewport got smaller than their basis.
Community feedback
- @DrKlonkPosted over 3 years ago
Hi Jeremy,
Nice job overall! Some things I've noticed:
The third rating box should be:
justify-content: flex-end
(instead ofend
).The stars wrap from 640-653 pixels wide for the middle rating, that looks a bit weird. Also, from 792 to 426 pixels wide the stars seem to move upon resizing. They don't align properly with the other ratings either.
All this is because the rating__stars resizes because of the flex-shrink, but the stars have a fixed width. I think it is better to remove the flex-shrink from this class.
Btw,
flex: 0 1 auto
is the default, so you don't even have to set the growth and shrink explicitly!Cheers, Joran
1@lanechangerPosted over 3 years ago@DrKlonk Thanks for the review Doc :)
Can you explain the difference between flex-end and end? Or refer me to an article about them? It seems like chrome is more compatible with flex-end?
Good call about the flex defaults. Would you recommend only setting the flex-basis or since the default for basis is auto, we can just set the width?
0@DrKlonkPosted over 3 years ago@lanechanger Basically neither
justify-content: end
, norjustify-content: start
should do anything for a flexbox container. Therefore, they both default tojustify-content: flex-start
.It does seem to work in Firefox, but in my Chrome it just doesn't. You can see the support for it here.
Justify-content is also a property for CSS grid, where
end
is a valid value. Check out this article for the ultimate flexbox guide. You can see the current proper values for it.Maybe
justify-content
also does something without either Flex or Grid, but I've never used it like that.On flex-basis: It's regarded as good practice to use the flex-basis instead of width or height. This article tells you why.
Cheers!
1 - @ApplePieGiraffePosted over 3 years ago
Hello there, Jeremy Ng! 👋
Nice job on another challenge! 👏
A few things I'd like to suggest are,
- Adding a little bit of space (using margin/padding) between the heading/description and the review boxes to the right of them in the desktop layout (so that there's a little bit of room between them, even when the width of the screen decreases).
- Taking a look at your solution report and trying to clear up the few errors that are there (it looks like
backquote
isn't an HTML element—perhaps you meantblockquote
?). - IDK why, but the third review box isn't shifted to the right in Chrome (like the second block quote). 🧐
Keep coding (and happy coding, too)! 😁
1@lanechangerPosted over 3 years ago@ApplePieGiraffe
Heya APG, thanks for the review as always! :)
OMG I was looking up the HTML error and trying to google why my backquote tags weren't working and couldn't find anything, the answer is now obvious that I have dreamed up this made up tag XD
Hopefully the justify-content: flex-end solves the 3rd review box. I was using end before and I guess there is a difference between them after all!
1
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