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

QR Code Component using CSS Flexbox

@saumyaranjan1111

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


I found it difficult to shrink the image size down to fit to the outer card div. I want to know if there was a better way to do this project only using flexbox and grid and using as less native css styling as possible.

Community feedback

@i-amWin

Posted

You can do something like this

HTML:

<div class="card">
<img src="./images/image-qr-code.png" alt="qr code" class="card__img" />

<div class="card__content">
</div>
</div>

CSS:

img {
display: block;
max-width: 100%;
}

.card {
width: min(335px, 100% - 2rem);
background-color: hsl(0deg, 0%, 100%);
padding: 1rem;
border-radius: 1rem;
}
.card__img {
width: 100% /* Optional, if width of img is less than width of card */
border-radius: 10px;
}

Marked as helpful

1

@saumyaranjan1111

Posted

@i-amWin Thank you for reading my code and commenting, I hadn't thought of making it a block and then limiting the max-width of the img. Thanks again!

0

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