Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

First QR code challenge

@donnol87

Desktop design screenshot for the QR code component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


For some reason I got completely lost in git on this challenge. I finally got to the end of it. Phew! I also think that I might not have this fully optimised for mobile (?).

In the end I sort of cheated when attempting to center div1 in the middle of the page. I wanted to use flexbox to align it vertically but couldn't get it to work so I simply gave it a 20vh margin-top.

Probably not the best approach but I welcome any feedback on this. Thanks in advance,

Donn

Community feedback

Lucas 👾 104,420

@correlucas

Posted

👾 Hello Donn, congratulations for your solution!

Your design elements are just perfect, but as you said you can have a better way to align this container to the center.

I know that you've used height: 20vh and works, but a best practice in this case is use display: flex; and min-height: 100vh in the body to align the child element. The child align to the body with min-height: 100vh because the child element use its parents size to get the alignment, so the body has 100% of the viewport the child will ever align to the screen center. Hope this was a good explaination, but you can write me if dont.

You can also improve even more your solution making your component responsive, you can not that if you scale down the window, the component will not behave responsive due its fixed width to fix it you need only to replace width with max-width inside the container and you'll not that the text elements will start to broke lines and the image scale properly.

Hope it helps and feel free to ask me any question.

Happy coding!

Marked as helpful

0

@donnol87

Posted

@correlucas hi there. Thanks for your feedback. Quick question, which section do I need to move from a fixed width to a max-width? I had a look back over my code and it seems I used max-width from the beginning? Although, my container doesn't scale correctly so I might have gone wrong.

0
Lucas 👾 104,420

@correlucas

Posted

@donnol87 I've check your css file and I think is the image that's not allowing the container to be responsive due the width: auto;

#image{ 
     height:250px; 
     width: auto; 
     border-radius: 20px;

Use instead max-width: 100%; to make the image grow 100% the container, remove the heightand setdisplay:block ` to the img for a better scaling.

0

@Badhrikr

Posted

Hello your solution is superb,

My only suggestion is ,Apply these to your stylesheet

body{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
}

Remove the margin top on the box1

Use main tag as your box1 to remove accesibility issues

Happy coding.

Marked as helpful

0

@donnol87

Posted

@Badhrikr thank you SpiderMan!!

1

Please log in to post a comment

Log in with GitHub
Discord logo

Join 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