@correlucas
Posted
๐พHi Mustapha, congrats on completing this challenge!
The approach you've used to center this card vertically is not the best way, because using margins you don't have much control over the component when it scales. My suggestion is that you do this alignment with flexbox
using the body as a reference for the container.
The first thing you need to do is to remove the margins used to align it, then apply min-height: 100vh
to make the body height size becomes 100% of the screen height, this way you make sure that whatever the situation the child element (the container) align the body with display: flex
and align-items: center
/ justify-items: center
.
remove the margins:
.display {
display: flex;
flex-direction: column;
background-color: hsl(0, 0%, 100%);
width: 17rem;
align-items: center;
justify-content: center;
margin: auto;
/* margin-top: 5rem; */
/* padding: 0.8rem; */
border-radius: 0.5rem;
}
USE FLEX AND MIN-HEIGTH TO ALIGN:
body {
display: flex;
background-color: hsl(212, 45%, 89%);
min-height: 100vh;
align-items: center;
justify-content: center;
flex-direction: column;
}
Your html code is not optimized yet, since its too long and have some unnecessary elements. To make it clean you start by removing some unnecessary <div>
. For this solution you wrap everything inside a single block of content using <div>
or <main>
(better option for accessibility) and put inside the whole content <img>
/ <h1>
and <p>
.
<body>
<main>
<img src="./images/image-qr-code.png" alt="Qr Code Image" >
<h1>Improve your front-end skills by building projects</h1>
<p>Scan the QR code to visit Frontend Mentor and take your coding skills to the next level</p>
</main>
</body>
โ๏ธ I hope this helps you and happy coding!
Marked as helpful
@Farouk-ayo
Posted
@correlucas that was a wrap of it all.Thanks You Lucas.