html center a div
To vertically center a `div` in the body of HTML, you can use either Flexbox or CSS Grid:
*Flexbox:*
css
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
}
*CSS Grid:*
css
body {
display: grid;
place-items: center;
height: 100vh;
margin: 0;
}
Test your knowledge with interactive quizzes.
Prepare for interviews with curated question sets.
Ask your coding-related doubts and get answers.
Earn certifications to enhance your resume.
Hands-on projects to improve your skills.
Test your knowledge with interactive quizzes.
Prepare for interviews with curated question sets.
Add your technical blogs and read technical topics.
Earn certifications to enhance your resume.
Hands-on projects to improve your skills.
People Also Asked |
---|