Design comparison
Solution retrospective
Hello Everybody 👋
As always, any feedback is much appreciated!
Specific feedback I would love to hear:
-
Some numbers are hardcoded to try and match the design as close as possible. Is the use of things like
.button { margin-top: 4rem; }
appropriate? Or are there better ways to approach the layout of the card to avoid things like this? -
What are the best use cases for flexbox? Would flexbox be better for the layout of the cards in this specific project?
-
Could I have made better use of
@media
for layout control? Any general tips for best practice use of@media
?
Cheers! 😊
Community feedback
- @FahatmahPosted almost 2 years ago
Hello Kegan! 👋
To answer you first question, you can try flexbox when the screen is in the desktop size, you see in the designs the first three elements which are the
img
,h2
, andp
, you can set the alignment toflex-start
or you can just set thea
toflex-end
This is what I mean:
.card { display: flex; flex-direction: column; } .card a { align-self: flex-end; }
If the
.card a
won't work, just addjustify-self: flex-end;
Hope that works. 😁
1@KeganFPosted almost 2 years ago@Fahatmah Thanks for your feedback!
Using flexbox, I was able to find a way to recreate the same spacing as
.button { margin-top: 4rem; }
.After some experimenting, here's what ended up working:
/* Setting a specified height for the card creates more room for the content to be spaced out */ .card { height: 450px; display: flex; flex-direction: column; } /* Turning on flex-grow for the paragraph above the button allows it to fill the extra space within the card */ .card > p { flex-grow: 1; }
The reason I left out
align-self: flex-end
is becausealign-self
uses the cross axis for positioning. Because.card
is usingflex-direction: column
, the cross axis is horizontal and positioning an element withalign-self: flex-end
(in this case) will align it with the right edge of the container.The reason I left out
justify-self: flex-end
is because thejustify-self
property is not used in flexbox, which I read about here.There's still more learning I have to do before I'm more confident with all the in-depth details of flexbox, so if I've missed anything please do let me know!
Cheers! 😊
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