Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted almost 3 years ago

Responsive QR-component using Flexbox

Stacey•30
@staceysav
A solution to the QR code component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


This is the first project that I did myself, so any comments are more than welcome.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • PhoenixDev22•16,830
    @PhoenixDev22
    Posted almost 3 years ago

    Hello Stacey,

    Congratulation on completing this frontend mentor challenge. Excellent work!I see you have received some incredible feedback , if you don't mind me reiretating some of them:

    • You should use <main> landmark to wrap the card. HTML5 landmark elements are used to improve navigation experience on your site for users of assistive technology.
    • In my opinion, the image is an important content. The alternate text should indicate where the Qr code navigate the user : like QR code to frontend mentor not describes the image. Also the alternate text should not be hyphenated, it should be human readable.
    • Never use <div> and <span>alone to wrap a meaningful content. Just keep in mind that you should usually use semantic HTML in place of the div tag unless none of them (the semantic tags) really match the content to group together. By adding semantic tags to your document, you provide additional information about the document, which aids in communication. For the reason stated before, in this challenge, you can use <h1> to wrap card__title and <p> for the description.
    <h1 class=”card__title”> Improve your front-end skills by building projects</h1>
    <p class=”card__text”> Scan the QR code to visit Frontend Mentor and take your coding skills to the next level</p>
    
    • In order to center the card on the middle of the page , you can use the flexbox properties and min-height: 100vh for the <body> add a little padding to the body that way it stops the card from hitting the edges of the browser. You can remove the unnecessary div .screen-container. You can remove position: relative ; z-index: -1
    • An element with width:100vw can extend below the vertical scrollbar of your browsers, inducing the apparition of horizontal scrollbars along with an unwanted side scroll. Use width:100% to the body instead will extend across the viewport but will always stop at the scrollbar.
    • width: 285px; an explicit width is really not a good way to have a responsive layout . Consider using max-width to the card in rem instead .
    • height: 470px;It's not recommended to set height to component, let the content of the component define the height.
    • Consider using rem and em units as they are flexible, specially for font size better to use rem. If your web content font sizes are set in absolute units, such as pixels, the user will not be able to re-size the text or control the font size based on their needs. Relative units “stretch” according to the screen size and/or user’s preferred font size, and work on a large range of devices.
    • Remember a css reset on every project. That will do things like set the images to display block and make all browsers display elements the same.

    Overall, Your solution looks great . Hopefully this feedback helps.

    Marked as helpful
  • Vanza Setia•27,715
    @vanzasetia
    Posted almost 3 years ago

    Hi, Stacey! 👋

    Congratulations on completing this challenge! 🎉

    It's really important to use semantic HTML. It is because good for accessibility and SEO. This way, the assistive technologies can understand the page content. So, you swap the card__title div with h1 and card__text div with p instead. Also, swap the card div with main element to indicate that the card is the main content of the page.

    Then, I recommend using the body element as the container of the card element instead of using an extra div. This way, you can create the website without any div since everything can be done with semantic HTML.

    That's it! I hope this helps! 😊

    Marked as helpful
  • Lucas 👾•104,160
    @correlucas
    Posted almost 3 years ago

    👾Hello Stacey, congratulations for your first solution and 😎 welcome to the Frontend Mentor Coding Community!

    I saw that you've used margins and position relative to give the container its alignment, this works but is really tricky to control all the content. My advice for your is to use flexbox to create this alignment. For example, first of all add to the body min-height: 100vh to make the body display 100% of the browser screen size and display: flex e flex-direction: column to align the child element (the container) vertically using the body as reference.

    Here's the fixes I did to your code:

    .screen-container {
        /* height: 100vh; */
        /* max-width: 320px; */
        /* background-color: hsl(212, 45%, 89%); */
        /* position: relative; */
        display: flex;
        justify-content: center;
        align-items: center;
        /* z-index: -1; */
    }
    
    .card__image {
        /* width: 100%; */
        max-width: 100%;
        /* height: 60%; */
        border-radius: 10px;
        display: block;
    }
    
    .screen-container {
        /* height: 100vh; */
        /* max-width: 320px; */
        /* background-color: hsl(212, 45%, 89%); */
        /* position: relative; */
        display: flex;
        justify-content: center;
        align-items: center;
        /* z-index: -1; */
    }
    
    .card {
        /* height: 470px; */
        max-width: 285px;
        background-color: white;
        border-radius: 20px;
        box-shadow: 5px 15px hsl(217deg 8% 61% / 5%);
        padding: 13px;
        /* position: absolute; */
    }
    

    👋 I hope this helps you and happy coding!

    Marked as helpful
  • Vongai O Machingura•80
    @livvyvi3
    Posted almost 3 years ago

    Hi Stacey Good way to go. You may look more into CSS grids so you may apply media queries. The CSS grid is a newer standard that makes it easy to build complex responsive layouts. It works by turning an HTML element into a grid, and lets you place child elements anywhere within. The you may use media queries to control responsive component layouts for the website.

    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 1st-party linked stylesheets, and styles within <style> tags.

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.

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