qr-code-component using css and html, used positions and images.
Design comparison
Solution retrospective
i had trouble with the length and width of the project, finding the correct length and width. I could only make mine for full screen 2560 Γ 1600 resolution.
Community feedback
- @MelvinAguilarPosted almost 2 years ago
Hello there π. Good job on completing the challenge !
I have some suggestions about your code that might interest you.
Styles:
- Remove the max-width and height of the * selector, let it occupy 100% of the screen width. When you set a fixed width, it will only work well when the viewport has the same width,
- There are some lines of text that are unnecessary, delete or comment them out: line github
-
Centering an element with
position: absolute
would make your element behave strangely on some screen sizes, "there's a chance the content will grow to overflow the parent". You can use Flexbox or Grid to center your element. You can read more about centering in CSS here π.Before trying to make your solution look like the picture, you should try to fix your solution by removing all absolute positions.
.design { background-color: hsl(212, 45%, 89%); min-height: 100vh; display: grid; place-content: center; /* width: 1200px; */ /* height: 700px; */ /* position: relative; */ /* left: 120px; */ /* right: 120px; */ /* top: 64px; */ /* bottom: 64px; */ } .container { /* position: absolute; */ /* width: 300px; */ max-width: 300px; /* height: 420px; */ background-color: hsl(0, 0%, 100%); /* left: 450px; */ /* right: 450px; */ /* top: 140px; */ /* bottom: 140px; */ border-radius: 25px; /* padding-top: 15px; */ /* padding-bottom: 15px; */ /* padding-left: 15px; */ /* padding-right: 15px; */ padding: 15px; /* The padding property is a shorthand property for all the paddings*/ } .container img { /* position: absolute; */ /* width: 250px; */ /* height: 250px; */ /* left: 40px; */ /* right: 40px; */ width: 100%; border-radius: 15px; } .container h2 { /* position: absolute; */ color: hsl(218, 44%, 22%); /* top: 250px; */ font-size: 17px; margin: 15px; } .container p { /* position: absolute; */ color: hsl(220, 15%, 55%); font-size: 15px; /* top: 350px; */ margin: 15px; }
HTML π:
- Use the
<main>
tag to wrap all the main content of the page instead of the<div>
tag. With this semantic element you can improve the accessibility of your page.
Alt text π·:
- The
alt
attribute should not contain underscores or hyphens, it must be human readable and understandable.
- The
alt
attribute should not contain the words "image", "photo", or "picture", because the image tag already conveys that information.
-
The
alt
attribute should explain the purpose of the image. Uppon scanning the QR code, the user will be redirected to the frontendmentor.io website, so a betteralt
attribute would beQR code to frontendmentor.io
If you want to learn more about the
alt
attribute, you can read this article. π.
CSS π¨:
- Instead of using pixels in font-size, use relative units like
em
orrem
. The font-size in absolute units like pixels does not scale with the user's browser settings. This can cause accessibility issues for users who have set their browser to use a larger font size. You can read more about this here π.
-
You should use a CSS reset to remove the default browser styles and make your page look the same in all browsers.
Popular CSS resets:
I hope you find it useful! π
Happy coding!
Marked as helpful0@floppitommiiiiiPosted almost 2 years agoThank you so much, I really appreciate your comment.
1 - @AhmedMahroussPosted almost 2 years ago
good jop my bro Congrats on completing your challenge!ππ»If you have any questions or need further clarification, feel free to reach out to me. Happy Coding! ππ
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