Design comparison
Solution retrospective
I encountered challenges in implementing the media screen sizes using CSS. I would appreciate being assisted with that.
Community feedback
- @correlucasPosted about 2 years ago
๐พHi @Sanderson-Nyange, 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:
- Something that can be a time saver for you is to use a CSS RESET to remove all default settings for margins, making the images easier to work, see the article below where you can copy and paste this CSS code cheatsheet: https://piccalil.li/blog/a-modern-css-reset/
- Use
<main>
instead of a simple<div>
this way you improve the semantics and accessibility showing which is the main block of content on this page. Remember that every page should have a<main>
block and that<div>
doesn't have any semantic meaning. - Replace the
<h3>
containing the main title with<h1>
note that this title is the main heading for this page and every page needs one h1 to show which is the most important heading. Use the sequence h1 h2 h3 h4 h5 to show the hierarchy of your titles in the level of importance, never jump a level. - Add a margin of around
margin: 20px
to avoid the card touching the screen edges while it scales down. - Use relative units as
rem
orem
instead ofpx
to improve your performance by resizing fonts between different screens and devices. These units are better to make your website more accessible. REM does not just apply to font size, but to all sizes as well.
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 helpful0 - @ojaswishivamPosted about 2 years ago
Hey @Sanderson-Nyange, here are some suggestions to improve your code:
-
auto is not a valid value for padding property, but you can use auto in margin property
-
The Alt Tag Description for the image needs to be improved upon. You want to describe what the image is; they need to be readable. Assume youโre describing the image to someone.
-
You have import Google Fonts of weight 400 and 700 in your project, Here is an example of how you can do it:
<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2? family=Outfit:wght@400;700&display=swap" rel="stylesheet">
-
Use External CSS in your code.
-
Use Flexbox or CSS Grid for the alignment Helpful Links: CSS Grid Flexbox
-
For Media Queries, you can visit this helpful website: Media Query
This is how the same challenge done by me looks! https://ojaswishivam.github.io/qr-code-component-solution-/
The Media Query used by me:
@media only screen and (max-width:629px)
Happy Coding! ๐ป๐
Marked as helpful0 -
- @MelvinAguilarPosted about 2 years ago
Hi @Sanderson-Nyange ๐, good job completing this challenge, and welcome to the Frontend Mentor Community! ๐
Here are some suggestions you might consider:
- Extract all selectors and remove media queries, in this challenge there is no need to implement a media query to.
- Add descriptive text to the
alt
attribute of the images. The text must clearly describe the image. The alt attribute enables screen readers to read the information about on-page images and will be displayed instead if an image file cannot load. - The container isn't centered correctly. You can use flexbox to center elements:
Links with more information:
- The Complete Guide to Centering in CSS.
- A Complete Guide to Flexbox (CSS-Tricks).
- How TO - Center Elements Vertically (W3Schools).
- CSS Layout - Horizontal & Vertical Align (W3Schools).
.
- Try to use semantic tags in your code. Click here for more information.:
With semantic tags:
<body> <main class="card"> . . . </main> <footer class="attribution"> . . . </footer> <body>
In short, your styles should look like this:
body{ /* Center with flexbox*/ margin: 0; width: 100%; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; background-color: hsl(212, 45%, 89%); font-family: 'Outfit', sans-serif; overflow: hidden; } img{ width: 100%; border-radius: 10px; } .card{ border-radius: 10px; background-color: hsl(0, 0%, 100%); max-width: 250px; min-height: 400px; padding: 14px; padding-bottom: 40px; /* margin-top:10% ;*/ /*margin-left: 40%;*/ } h3{ font-weight: 700; text-align: center; font-size: 1.3em; } p{ font-weight: 400; text-align: center; font-size: .9em; } .attribution { font-size: 11px; text-align: center; padding-top:4%;} .attribution a { color: hsl(228, 45%, 44%); }
I hope those tips will help you.
Good job, and happy coding!
Marked as helpful0
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