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

Price grid and flex website challenge

@fellipemnds

Desktop design screenshot for the Single price grid component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


The property "margin: auto" only centralizes it horizontally, but I would like to do it vertically as well, so, how can I centralize the #container div, both horizontally and vertically?

Community feedback

Priya Garg 200

@Priya366

Posted

Hi Felipe! You have done an awesome work and your code is easy to read. Good job!

As per your query, You can center container by styling body as follows:

** body { display: flex; justify-content: center; align-items: center; height: 100vh; } **

Really hope this will be helpful.

!!!One more thing, do check and improve your accessibility issues too!!!

Marked as helpful

1
Travolgi 🍕 31,420

@denielden

Posted

Hi Mateus, great work on this challenge! 😉 using margin to center elements might be almost deprecated by now

Here are a few tips for improve your code:

  • add main tag and wrap the card for improve the Accessibility
  • remove all margin from card class
  • use flexbox or grid to the body to center the card. Read here -> best flex guide
  • after, add min-height: 100vh to body because Flexbox and Grid aligns child items to the size of the parent container

Overall you did well 😁 Hope this help!

Marked as helpful

1

@mjbaga

Posted

Hi, Mateus. You can centralize elements inside a grid or flex vertically and horizontally using "place-items: center;". It's the short version of "justify-items: center;" and "align-items: center;".

For flex, depends on which direction if it's column or row, justify-items or align-items.

For non-grid or non-flex, try "vertical-align:" sub or middle, etc. You'd have to manually check.

Last would be just adding padding on inline elements.

Marked as helpful

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