Design comparison
Solution retrospective
Knowing only the basics of css and htm, it was hard for me to center the element vertically on the page. I did this with position absolute, subtracting half the width and height of the element in the margin. This was the most difficult for me. In further study, I think it will be easier for me to get centering with flex.
Community feedback
- @correlucasPosted about 2 years ago
👾Hi @explorem, congratulations on your solution!👋 Welcome to the Frontend Mentor Coding Community!
Great solution and a great start! From what I saw you’re on the right track. I’ve few suggestions for you that you can consider adding to your code:
Your solution is great and the code is working, but the HTML structure can be reduced by removing unnecessary divs, all you need is a single
<main>
or<div>
to keep all the content inside, and nothing more. The ideal structure is thediv
and only the image, heading, and paragraph.Here’s one example to show can be cleaner this HTML structure:
<body> <main> <img src="./images/image-qr-code.png" alt="QR Code Frontend Mentor" > <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>
To reduce the CSS you can use the direct selector for each element instead of using
class
this way you have a code even cleaner, for example, you can select everything using the direct selector for (img, h1, and p, main).Here's my solution for this challenge if you wants to see how I build it: https://www.frontendmentor.io/solutions/qr-code-component-vanilla-cs-js-darklight-mode-nS2aOYYsJR
✌️ I hope this helps you and happy coding!
Marked as helpful1@exploremPosted about 2 years agoHi @correlucas! :) Thank you! Your feedback is very helpful for me. I improved the appearance of the code in HTML and CSS. You're right, it looks so much better! Of course I would love to see your work✌️
0 - @MelvinAguilarPosted about 2 years ago
Hi @explorem, good job for completing this challenge! 👋
Here are some suggestions to improve your code:
Your element is centered, here I leave you another alternative: You can use flexbox to center things, this center the .wrap container inside the body element
body { width: 100%; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; }
Or You can use Grid layout Reference
body { display: grid; place-content: center; /* The place-content property is a shorthand property for: justify-content and align-content*/ }
Update
width: 320px;
tomax-width: 320px;
in .wrap and remove position if you wantMore information: A Complete Guide to Flexbox (CSS-Tricks) | https://www.w3schools.com/howto/howto_css_center-vertical.asp
- Try to use semantic tags in your code. More information here:
Without semantic tags:
<body> <div class="wrap"> </div> <body>
With semantic tags:
<body> <main class="wrap"> </main> <body>
- Add descriptive text in the
alt
attribute of the images, the text should describe the image, The alt attribute enable screen readers to read the information about on-page images and will be displayed instead if an image file cannot load
I hope those tips will help you.
Good Job !
Marked as helpful1@exploremPosted about 2 years agoHi @MelvinAguilar !
Thank you! Your feedback is very helpful for me. I used the solution you proposed in the code. I used a flexbox for centering and it works great. I update width: 320px; to max-width: 320px; in .wrap. I also use main tag. In the next challenge, I will use new ways to center the block.
Thanks!
0 - @DeolabestPosted about 2 years ago
Hi @explorem, great job!
I will suggest you take the attribution out of the container as it's affecting the beauty of the project. You can move it below the container like many of us do.
Keep doing your good job.
1@exploremPosted about 2 years ago@Deolabest
Thanks for the hint. I will do as you write!
0
Please log in to post a comment
Log in with GitHubJoin 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