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

3-column preview card component: Mobile first using Flex

P
Danielle•50
@DanielleLensly
A solution to the 3-column preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


I had to use !important thrice to force css changes. I'd like some advice on how to make the changes without the important tag.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Raza Abbas•770
    @RazaAbbas62
    Posted over 1 year ago

    Hi, For button you are setting its color on button a selector, while for hover you are just using button, so due to less specificity of button as compared to buutton a u need to add important tag.

    For the width of main, you are using width two times in the same selector , that's why it is causing problem,

    And flex-direction:row is working fine without important tag.

    I hope this will help.

    Enjoy Coding:)

    Marked as helpful
  • Emmilie Estabillo•5,600
    @emestabillo
    Posted over 1 year ago

    Hey @DanielleLensly, great job on completing your project! Some recommendations:

    CSS:

    • add a reset to your stylesheet
    • use relative units such as rem instead of px
    • lines 116 and 122 are identical as mentioned previously. So are lines 80 and 141.
    • For the width of the cards:
      1. set amax-width in rem on the main container and
      2. remove all widths and max-widths on the cards. Use padding to keep the content from touching the gutter
    • For centering the component on the page:
      1. Remove position: absolute from main and position: fixed from attribution. You don’t even need static since that’s the default
      2. use flex (or grid) on the body:
    body {
        min-height: 100vh;
        display: flex;
    
        flex-direction: column;
    
        align-items: center;
    
        justify-content: center;
    }
    

    HTML:

    • a tags redirect users to another page/section of a site, which is what we need here. Instead of buttons which perform an action (ex. submitting information or hiding/showing divs)
    • div class="main” can be replaced by <main>
    • Write your markup as if you are writing a word document. There should only be one h1 (main heading) on a page. There’s no clear heading in the design, but you can add one with the sr-only class. Check out this article and here's another one for the headings.

    Hope this helps!

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

Frontend Mentor for Teams

Frontend Mentor for Teams helps companies and schools onboard and train developers through project-based learning. Our industry-standard projects give developers hands-on experience tackling real coding problems, helping them master their craft.

If you work in a company or are a student in a coding school, feel free to share Frontend Mentor for Teams with your manager or instructor, as they may use it to help with your coding education.

Learn more

Oops! 😬

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

Log in with GitHub