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 HTML/CSS

#bem

@dzitting

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


This is a solution to the QR code component challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

I started first with reviewing the design and deciding how the HTML might be structured for the desired outcome. Then I broke the design down into different elements/tags. Starting first with the container that wraps around the entire card. Then I added a figure to hold the img. I broke the text apart from the img by separating it in a div. Once the HTML structure was complete, I moved into the styling and started centering the elements. At this point I needed to resize the image/figure, and align the text.

After this was complete, I moved focus to adding in the last details with border-radius and a drop-shadow filter. I adjust the text colors and added the background-color.

  • Semantic HTML5 markup
  • CSS custom properties
  • Flexbox

I utilized margin: 0 auto; through this challenge, as I didn't want to cause a major shift to the elements when using display: flex.

I am most proud of the following CSS, due to the fact, I am used to creating percentages that allow for easier responsive design. However, in this challenge the object was not supposed to resize based on mobile/desktop. The width was set to a hard number and that maintains throughout the resizing.

div.container {
    background-color: aliceblue;
    width: 325px;
    overflow: hidden;
    margin: 0 auto;
    border-radius: 20px;
    padding: 10px;
    filter: drop-shadow(0 0 15px #0000003e);
}

Community feedback

P
Jeuri Morel 1,405

@JeuriMorel

Posted

Hey Denise, nice job with this one. You said that you used margin: 0 auto; instead of display: flex; because of shifting elements. Did you try adding the following along with display: flex; to the body?

    align-items: center;
    justify-content: center;

It perfectly centers the card with no shifting issues. If you do this there's no need for padding-top: 50px; on the body or the margin on the card.

Also, try linking directly to the solution for easier access.

1

@dzitting

Posted

@JeuriMorel Thanks so much for the feedback! In that instance, it definitely would have been smarter to use the display: flex.

I appreciate you noting that!

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