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

HTML CSS Javascript

@mbeka02

Desktop design screenshot for the Advice generator app coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
  • API
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


What's the best way to place a div in the center of a page, can you do it without using absolute positioning?

I got my solution from stackoverflow (https://stackoverflow.com/questions/356809/best-way-to-center-a-div-on-a-page-vertically-and-horizontally)

Community feedback

@0-BSCode

Posted

Awesome work! With regards to your question, another way you could center the card in the page is giving your html element a display of grid and setting align-items: center`. Although, the method you mentioned is also something I use regularly. Cheers!

Marked as helpful

0

@Maikolrm

Posted

Hi! this is one of the most simple ways to do it:

/* main container */
.container {
   min-height: 100vh;
   display: flex
}

/* inner container */
.container__child {
    margin: auto
}

And that's it... I hope this can help :)

Marked as helpful

0

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