QR code card component using HTML and CSS
Design comparison
Solution retrospective
How to use Flexbox effectively to design this? Although I have used Flexbox here, I am a bit unsure if I have used it effectively. What can be some other ways to make the same design?
Community feedback
- @VCaramesPosted about 2 years ago
Hey @YashasveeBasotia, great job on this project!
Some suggestions to improve you code:
-
Your use of Flexbox is good. You can also** achieve the same results** by removing all flex properties and remove the height from your .container class.
-
To make it easier to deal with CSS , have more control over your content, and want to ensure that everything will look the same regardless of browser used I suggest taking a look at CSS Resets.
CSS Resets are customizable for your preference.
Here are few CSS Resets that you can look at and use to create your own CSS Reset or just copy and paste one that already prebuilt.
https://www.joshwcomeau.com/css/custom-css-reset/
https://meyerweb.com/eric/tools/css/reset/
http://html5doctor.com/html-5-reset-stylesheet/
Happy Coding!
0 -
- @correlucasPosted about 2 years ago
👾Hi @YashasveeBasotia, congratulations on your first 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:
1.Add the website favicon inserting the svg image inside the
<head>
.<link rel="icon" type="image/x-icon" href="./images/favicon-32x32.png">
2.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.3.The HTML structure is fine and works, and you can reduce at least 20% of your code by cleaning the unnecessary elements, you start cleaning it by removing some unnecessary
<div>
. For this solution you wrap everything inside a single block of content using<div>
or<main>
(better option for accessibility) and put inside the whole content<img>
/<h1>
and<p>
.<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>
✌️ I hope this helps you and happy coding!
0 - @denieldenPosted about 2 years ago
Hi Yashasvee, congratulations on completing the challenge, great job! 😁
Some little tips for optimizing your code:
- add
main
tag and wrap the card for improve the Accessibility - also you can use
article
tag instead of a simplediv
to the container card for improve the Accessibility - remove
height
fromcontainer
class - instead of using
px
use relative units of measurement likerem
-> read here
Hope this help! Happy coding 😉
0 - add
- @nzewiPosted about 2 years ago
Congrats on completing this challenge Yashasvee You have a great solution there.
Your use of flexbox is decent, however, you can improve.
Here are my suggestions:
.container { width: 300px; height: 460px; background-color: hsl(0, 0%, 100%); border-radius: 20px; display: flex; flex-direction: column; justify-content: space-around; align-items: center; padding: 15px; box-shadow: 0 8px 20px 1px hsl(211deg 16% 74% / 33%); }
You have some redundant code there. This code below achieves the same result.
.container { max-width: 300px; background-color: hsl(0, 0%, 100%); border-radius: 20px; display: flex; flex-direction: column; padding: 15px; box-shadow: 0 8px 20px 1px hsl(211deg 16% 74% / 33%); }
1.Use
max-width
instead ofwidth
for more responsiveness. You don't need to specify theheight
for your card, let the content determine the height. This way it is more responsive2.You can use the
gap
property to space flex-items instead of margins.3.Using relative units like
rem
andem
instead ofpx
would make your site more responsive. Learn about them and use them in your next project.4.Ensure that all content on your page is contained within a landmark region, e.g Wrapping your container
<div>
inside a<main>
tag. This makes your HTML more semanticI hope this helps
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