Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted about 2 years ago

responsive page

Willian Padilha•40
@Williais
A solution to the QR code component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


I'm starting in css and what I felt the most difficulty with was centering the div.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Aimal Khan•2,260
    @Aimal-125
    Posted about 2 years ago

    Bro use position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); Or display: flex; justify-content: center; align-items: center;

    Marked as helpful
  • Account deletedPosted about 2 years ago

    Hello, Knowing you're starting out with css is helpful context for this project. There are a couple of things to note about your project.

    TLDR

    For further development look into the following topics: CSS BEM, Responsive Design, Relative and absolute units, and Semantic HTML.

    HTML

    1. Like the previous commenter mentioned, you should be using the MAIN element to encapsulate your pages main content. For further development, I would recommend you research the topic of Semantic HTML. You will often be using elements like main, nav, article, main, and footer in your projects.
    2. You shouldn't use Heading elements for size. This is a mistake many people starting can make. Headings should be used for document structure.

    CSS

    1. I can see why you imported a charset in your stylesheet, but its more common to link to the Google Fonts from the HTML. To do this you would copy the <link> code from google fonts and paste it into your HTML's head.
    2. As you develop in your journey, you'll find that using px for certain things becomes less common. I would recommend looking into relative and absolute units. For text it is more common to use rem.
    3. The previous comment referred to never using a height. Generally speaking, you should avoid using height, but if you absolutely have to, then it's recommended to use min-height. The reason for this is that setting a specific height can cause issues with responsiveness.
    4. It isn't an issue yet, as this is a fairly small project, but going forward I would recommend using classes more often. Selecting things by element can cause issues later on. To avoid this we often select things by their classes and then with a combinator we specify further if we need to. I would recommend picking a CSS naming convention to start getting familiar with it. I take inspiration from the BEM naming convention.

    Resources

    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements https://www.youtube.com/channel/UCJZv4d5rbIKd4QHMPkcABCw https://developers.google.com/fonts/docs/getting_started https://css-tricks.com/bem-101/

    Marked as helpful
  • hitmorecode•7,540
    @hitmorecode
    Posted about 2 years ago

    Congratulations on your effort well done. Here are a few changes you can do

    • Change your html structure to this
    <body>
    <main>
    <div>
    place your content in here
    </div>
    </main>
    </body>
    
    • To center the div you were almost there, you just need to add two things in your CSS
    body{
    display: flex; 
    width: 100%; /* you don't need this, remove it */
    height: 100%; /* change it to min-height: 100vh. this will place your card in the middle of the page */
    background-color: #d5e1ef;
    justify-content: center;
    align-items: center;
    }
    
    div{
    background-color: white;
    width: 280px;
    height: 450px;
    margin-top: 10%; /* because the card is already positioned with flexbox, you don't need this. Remove this line, this line causes other problem. when going to small screen size, the card will move upwards */
    border-radius: 20px;
    box-shadow: 0 6px 10px rgba(128, 128, 128, 0.219);
    text-align: center;
    }
    
    /* You defined the same font-family in two different places. You don't have to do this, just place the font-family on the body and it will apply for the entire page */
    div h2{
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: bold;
    color: #1d2a4a;
    padding: 0px 30px 0 30px;
    }
    
    div p{
    color: gray;
    padding: 0px 30px 0px 30px;
    font-size: 14px;
    font-family: 'Outfit', sans-serif;
    }
    

    One more tip, for this challenge is not that important due to the size of the content. For next challenges try to use more classes and / or id's. When the markup gets larger it will be hard to just style a div with css. If you have multiple layers of div's it will be more work to style them with css.

    Keep it up 👊

    Marked as helpful
  • Joachim•840
    @Thewatcher13
    Posted about 2 years ago

    Hi

    I've a few things to say:

    html

    • use a main landmark role
    • dont skip the heading order you cant have an h2 before h1
    • your alt on the img should be much more clear a qr code to where?

    css

    • There is no need to import a charset in your css..why did you do this?
    • dont use px for font sizes , but rem, look at the post from fedmentor called "why you should never use px for font size"
    • never set a height on a container the content provides the height
    Marked as helpful

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
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub