@ecemgo
Posted
Some recommendations regarding your code that could be of interest to you.
In order to make the card responsive and avoid repetition in your code, you can follow the steps below:
HTML
- You need to update the html structure in this way:
<body>
<main>
<div class="qr"><img src="images/image-qr-code.png" width="260" height="260"></div>
<div class="text1"><br>Improve your front-end<br> skills by building projects</div>
<div class="text2"><br>Scan the QR code to visit Frontend<br>Mentor and take your coding skills to<br>the next level</div>
</main>
<footer>
Challenge by <a href="https://www.frontendmentor.io?ref=challenge" target="_blank">Frontend Mentor</a>. <br>
Coded by <a href="https://github.com/BrunoSFiori">Bruno Fiori</a>.
</footer>
</body>
CSS
- If you want to make the card centered both horizontally and vertically, you'd better add flexbox and
min-height: 100vh
to thebody
- You can define
font-family
here to avoid repetition
body {
font-family: "Outfit", sans-serif;
background-color: hsl(212, 45%, 89%);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
}
- When you use flexbox in the
body
, you don't need to usemargin
in themain
to center the card - If you use
max-width
, the card will be responsive - You'd better give padding to give a gap between the content and the border of the card
- You can define
text-align
here to avoid repetition
main {
background: hsl(0, 0%, 100%);
/* width: 300px; */
max-width: 300px;
/* height: 500px; */
border-radius: 10px;
/* margin-left: auto; */
/* margin-right: auto; */
/* vertical-align: middle; */
/* margin-top: 200px; */
/* position: relative; */
padding: 20px;
text-align: center;
}
- In addition to that above, in order to make the card responsive and the image positioned completely on the card, you'd better add
width: 100%
to the img
img {
border-radius: 10px;
width: 100%;
}
- You've already defined the class name for text so you don't need to define them as
div.text1
. You'd better define them by the name - You can update texts and
footer
in this way:
.text1 {
/* font-family: "Outfit", sans-serif; */
color: black;
font-size: 25px;
/* text-align: center; */
/* position: relative; */
}
.text2 {
/* font-family: "Outfit", sans-serif; */
color: gray;
font-size: 15px;
/* text-align: center; */
/* position: relative; */
}
footer {
/* font-family: "Outfit", sans-serif; */
/* position: absolute; */
position: fixed;
bottom: 0;
/* color: black; */
/* height: 50px; */
text-align: center;
/* width: 99%; */
}
Hope I am helpful. :)