Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 1 year ago

Responsive landing page using CSS Flexbox

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

Solution retrospective


  1. I find it confused whether should I use width: 100% or max-width:100% for <img> tag.
  2. Sometimes I see people use a <div> to wrap outside <img>
Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Douo•940
    @Douoo
    Posted over 1 year ago

    Congrats on finishing the challenge 🎉. I have to say the choice between using width: 100% and max-width: 100% for the <img> tag depends on what you want to achieve with your images and how your layout is structured.

    1. width: 100%: This CSS rule will make the image take up 100% of the available width of its containing element. If the containing element's width changes, the image will scale accordingly.
    • Note that this can lead to image distortion if the image's aspect ratio is different from its container (since 100% refers to the parents width).
    1. max-width: 100%: sets the maximum width of the image to 100% of its containing element's width. This is commonly used to ensure that the image doesn't exceed its natural size and maintains its aspect ratio while resizing. It's a good choice for responsive design when you want the image to scale down to fit the container but not exceed its original dimensions.

    Remember, using a <div> to wrap an <img> can be a helpful technique, especially if you want more control over the layout and the behavior of the image. For example, you can use a <div> to create a container for the image and then apply a max-width: 100% to the image inside the <div>. This can be useful for adding padding, margins, or other stylings to the image container.

    Hope this helps you understand when to use width:100% and max-width:100% on imgs 😊

    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