Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 4 years ago

Mobile-first solution using CSS and Flexbox

Janne Tielinen•90
@Tielinen
A solution to the Four card feature section challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Hello everyone, this is my very first Frontend Mentor solution.

I tried to focus every detail on design as well as I could, and write well structured simple, easy to read code.

Is there simpler, or best-practises to place elements right/bottom corners of their containers? Like images are in this solution.

What is the best way to place info-cards to "cross" formation on desktop screens?

Where you think I did good? What one thing you would change in my code, why, and how?

Thanking in advance Janne

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Grace•32,130
    @grace-snow
    Posted over 4 years ago

    Hi @Tielinen,

    Ideally this is a CSS grid challenge, not flexbox (for the card grid). You're solution would have less HTML and be simpler to manage if you used CSS grid.

    If you want to keep using flex as you have done, it's still valid and fine to do, just a suggestion really 🙂

    It would be better with your flex grid if you used this approach:

    .info-cards-container {
        max-width: 1110px;  // instead of width
        gap: 1.5rem; // or however much gap you want to use
        align-items: center; // removes need for auto vertical margins on two cards targeted by IDs
    }
    

    I don't think you need to give the cards an exact width and height at any breakpoint.

    How you've positioned the images looks fine to me. Alternatives could be

    • making them background images (card would need a min-height and a load of padding at the bottom to prevent overlap if extra text was ever added in future)
    • positioning image absolutely (card would need position relative, and all the first bullet points properties apply)
    • image could be set to display block, with margin-left auto
    • image could be placed inside a block element that has text-align: right;

    Those images don't need alt text though. Leave the alt blank like alt="" and add ara-hidden="true"

    It's really important for font-sizes to not be in pixels but use a relative unit, preferably rems. This allows the font sizes to scale predictably with user preferences. I would also use rems for things like widths, padding/margin and media queries, but that is more down to personal choice I think.

    The only other very minor things are that the card heading text color doesn't seem to match the design, and 1110px is very late to be triggering that desktop design. I think there's room for your media query to kick in sooner.

    Overall, really great work on this. Your HTML and CSS are well written and easy to understand, and the result looks good 👍

  • P
    Marko Nikolajević•1,095
    @MarkoNikolajevic
    Posted over 4 years ago

    Hi Tielinen,

    your first solution looks really good and the code is clear and readable! Nice done! :)

    • to place images on the right bottom you could set position: relative on the info-card class and remove styles you add on <div class="image-container"> and add these styles on it
    position: absolute;
    bottom: 0;
    right: set the value equals to the left padding of the card;
    
    • one more thing, you start using h2 and go down to h3, I would suggest you to start with h1 and then move down to h2 etc

    Anyway everything looks good!

    Keep coding :)

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

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.

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

Oops! 😬

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

Log in with GitHub