Mobile first solution using flexbox for QR component

Solution retrospective
Hi everyone, greetings from Prague,
I hopefully fixed all the stuff so it works on mobiles properly now.
Would be really great if someone can review the code itself.
Thank you a lot, Iva
Please log in to post a comment
Log in with GitHubCommunity feedback
- @grace-snow
Hi
You need to swap the second heading for a paragraph tag, and remove the word “image” from the img alt attribute.
This looks very broken for me on mobile because you’ve used explicit widths and heights and because of viewport units. To fix you need to
- change height 100vh on body to min-height so it can grow
- change the width of the card to max-width and use rem (or px if you’re not comfortable using rem yet). The image can be display block and max-width 100%, but the max width on the card will stop it growing too wide
- remove height on the card altogether, it is not needed and will only ever cause bugs. Let the height of the card be dictated automatically by the browser - it will be added up height of the cards contents, padding, and any vertical margins on that content. The height needs to be able to grow
Marked as helpful - @pazspera
Hello Iva!
Flexbox is the easiest way to get the card centered vertically and horizontally, it'll also save you the trouble of having to write media queries. On this challenge the size of the card remains the same so you could use the width on mobile to adjust the size of the card and that stays the same for desktop.
Rem or vh and vw is usually easier to use then pixels and it makes things responsive more easy as well. Here's a cool resource for flexbox if you want to dive a little deeper on it https://www.youtube.com/watch?v=u044iM9xsWU
Keep coding!
Marked as helpful - @JohnIdenyi
Nice work!
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