Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

3 Column Preview Card Component (Mobile-First)

Kegan 100

@KeganF

Desktop design screenshot for the 3-column preview card component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

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

Fat 850

@Fahatmah

Posted

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, and p, you can set the alignment to flex-start or you can just set the a to flex-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 add justify-self: flex-end;

Hope that works. 😁

1

Kegan 100

@KeganF

Posted

@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 because align-self uses the cross axis for positioning. Because .card is using flex-direction: column, the cross axis is horizontal and positioning an element with align-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 the justify-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
Fat 850

@Fahatmah

Posted

@KeganF Thank you for the article! Cheers too!

1

Please log in to post a comment

Log in with GitHub
Discord logo

Join 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