Qr code component main using a container div for the image and content
Design comparison
Solution retrospective
Made the following changes to better my code and make it more responsive.
-
Used a flex box for the body to align all elements to the center without having to mess with the width and height.
-
Used a flex box for the main container div to align elements in columns and center too.
-
Used the recommended fonts and colors in the style guide
Community feedback
- @ecemgoPosted over 1 year ago
Some recommendations regarding your code could be of interest to you.
HTML
In order to fix the accessibility issues:
- You need to replace
<div class="container">
with the<main class="container">
tag. You'd better use Semantic HTML, and you can also reach more information about it from Using Semantic HTML Tags Correctly. - Each main content needs to start with an h1 element. Your accessibility report states page should contain a level-one heading. So, you should use one
<h1>
element in the<main>
tag. You can replace your<h2>Improve your front-end skills by building projects</h2>
element with the<h1>Improve your front-end skills by building projects</h1>
element.
After committing the changes on GitHub and you need to deploy it as a live site. Finally, you should click generate a new report on this solution page to clear the warnings.
CSS
- In order to center the card easily and correctly, you can add
min-height: 100vh
to thebody
body{ min-height: 100vh; }
- You don't need to use
margin
in the.container
because you've used flexbox in thebody
to center the card, you can remove it. Additionally, flexbox you used in the.container
doesn't work so you can remove it as well. - If you want to make the card responsive, you can use
max-width
instead ofwidth
.container { /* display: flex; */ /* flex-direction: column; */ /* justify-content: center; */ /* align-items: center; */ /* margin: 100px auto; */ /* width: 300px; */ max-width: 300px; }
Hope I am helpful. :)
Marked as helpful0@apah-devPosted over 1 year ago@ecemgo this is everything I’ve been trying to fully understand Thank you so much for taking the time
1 - You need to replace
- @sufiyan0Posted over 1 year ago
In Your project folder you always find style-guide file try to read in and follow the color and font style.
body{ display: flex; align-items: center; justify-content: center; min-height: 100vh; } use this code to get your component in center of the screen
Marked as helpful0@apah-devPosted over 1 year ago@sufiyan0 I'll apply the changes and see the difference. Thanks Ahmed
0 - @Bader-IdrisPosted over 1 year ago
You can set the container in the middle of the screen whatever user changes it when you add these properties to it in CSS:
.container { position: absolute; top:50%; left: 50%; transform: translate(-50%, -50%); }
the new feature is transform, it has many lovely properties you can discover, I personally love it. Hope it's useful
Marked as helpful0@apah-devPosted over 1 year ago@Bader-Idris Thank you so much. I'm guessing this is responsive no matter the device that views in right?
0@ecemgoPosted over 1 year ago@apah-dev if you want the card to be responsive, you can check out what I recommend.
Marked as helpful0@apah-devPosted over 1 year ago@ecemgo Your recommendations align totally with my thoughts on how to solve the responsiveness and how to keep unnecessary lines of code from the project. I’m still adding things that I may not need as I’m just starting to fully grasp some of the concepts.
1
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