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 and CSS

Renardo PIneโ€ข 10

@Underworl

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


1)How do I center the main div vertically without margin or hard-coded values? 2)I styles the images and text before I worked on the position of the main div. Is this a bad way to do it? 3)I used the hsl values provided in the styles guide but my text editor Caret kept telling me a fallback value should be provided with hsl. What does this mean and what should I do?

Answers to any of these questions will be greatly appreciated. Thanks for checking out my solution.

Community feedback

Jen Mโ€ข 130

@jenmurph4610

Posted

Hi @underworl, nice work!

I found the use of the flex display property helpful in my version of this project, thanks to feedback I received. It made it so much easier to center the items within the body, but also center the items within the 'card' itself.

You could get rid of the divs within .container and leave just the three elements (img, p, p) within one div themselves. Arranging them with flex within that will then be easier. I was able to eliminate a lot of margin properties and such from my CSS when I did this.

Your first <p> should probably be a heading like <h1> too, I think that will eliminate one of your errors in the accessibility report, but with that you could also simplify more and eliminate the classes from all three and just target them with the selectors since there would be only one of each type.

I tend to work on the same before I work positioning as well. It seems to work well for me too but curious to see what others might input on that.

0

Renardo Pineโ€ข 50

@Pinedevs

Posted

@jenmurph4610 Thank you for the feedback. I'll try using less unnecessary divs and work on my use of flexbox.

It's good to know that the way I tend to work also can work well.

1
Lucas ๐Ÿ‘พโ€ข 104,420

@correlucas

Posted

๐Ÿ‘พHello Renardo, congratulations for your solution!

Answering your question:

To align it vertically, in my opinion, the best way is by using flexbox. To do that you need to add min-height: 100vh (this will make the container align to the parent element, in this case the body) because the body will display 100% of the view port height so will be centered vertically, but you need to add too display: flex and its flex alignments. See the code fixes below where I've removed the margins and added the flexbox:

body {
    min-height: 100vh;
    background-color: hsl(212, 45%, 89%);
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.container {
    /* height: 100%; */
    width: 350px;
    background-color: hsl(0, 0%, 100%);
    /* margin: 150px auto; */
    border-radius: 20px;
    text-align: center;
}

If you do this game tutorial, you'll learn a lot about flexbox and alignment: https://flexboxfroggy.com/

See if works for you bro!

0

Renardo Pineโ€ข 50

@Pinedevs

Posted

@correlucas I tried your code fix and it works. Thank you for the feedback and I'll be sure to check out that tutorial.

1
Lucas ๐Ÿ‘พโ€ข 104,420

@correlucas

Posted

@Pinedevs that's amazing

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