Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 8 months ago

Responsive Four Card Feature Section

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

Solution retrospective


What are you most proud of, and what would you do differently next time?

I love how I finally managed to put the text inside the cards in the top left corner and the icons in the bottom right corner.

What challenges did you encounter, and how did you overcome them?

I struggled so much with positioning of the little details, like text and icons, but eventually figured it out doing some research.

What specific areas of your project would you like help with?

I very happy with the mobile site but with the desktop site I have not managed to make it look just like the design. How do I bring the central 2 cards closer together? I have tried adding more rows and adjusting their star and end rows but it did not work.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Adriano•42,890
    @AdrianoEscarabote
    Posted 8 months ago

    Hey WajahatAli130, how’s it going? I was really impressed with your project’s result, though I have some advice that could be helpful:

    Avoid using the <br> tag in your HTML code. While <br> might seem like a simple way to break lines, it is considered bad practice and can lead to significant accessibility concerns. For users who rely on screen readers, the presence of <br> can be announced, which disrupts the flow of the content and creates a confusing experience.

    Instead of <br>, you should use semantic HTML to structure your content properly. For example, wrapping text in paragraphs (<p>) or using <div> containers for sections provides a cleaner and more accessible solution. This approach improves usability for screen readers and ensures that your content is presented in a meaningful way to all users.

    For more detailed guidance, refer to the MDN documentation on the <br> tag: MDN: Accessibility Concerns of <br>

    Pro Tip: Accessible web development isn't just a recommendation—it's essential for ensuring inclusivity on the web!

    Everything else looks great.

    Hope this helps! 👍

    Marked as helpful
  • calvinvin•1,170
    @calvinvin
    Posted 8 months ago
    1. "id" property is unique and you should not have two elements with same id value (i.e. your #image). Setting "image" as class name instead of id value would be appropriate by the way you used #image.

    2. "Position: absolute" (the way you control the position of your .card-text and #image) is usually avoided unless necessary, because the element of absolute position will pop out the whole layout (the "justify-items/contents" or "align-items/contents" properties on .supervisor can no longer have effect on .card-text and #image), and may ruin your other elements easily. Also you have to set relative position on one of the ancient element, set a size on the container, ...etc, which will take a lot more work and instead make elements harder to control.

    3. Many unnecessary properties were set:

    • the <div> outside the <img>. You can just use <img> without <div>.
    • the "width: 100%" of .cards. Removing it will make no difference.
    • the "height: 250px" on div will hard-code all <div> elements' height to 250px unless the subsequent css styling override it. And we usually don't want this behavior.
    • the "height: 100%" of .cards. But removing it will destroy the layout. That is because you hard-coded "height: 250px" on .cards. And you have to hard-code "height: 250px" because you set absolute position on .card-text and #image, therefore the browser cannot arrange height based on the elements automatically.
    • the "display: block" on .title. The child elements (two <p>) are all block elements, and the .title would be block element then.

    I strongly recommend the Kevin Powell's youtube channel. I believe you can learn a lot from it, as I just did recently, and save you a lot of ineffective hard work.

    Appendix after reading your "Solution retrospective":

    1. For you struggling positioning elements. Make good use of grid and flex for layout instead of using absolute position.
    2. To bring the central 2 cards closer, you have to get rid of the central blank grid cell. You set the grid as 3 columns, tell the browser that the left and right card have row span of 2, and the browser will fill the four cards in the grids just like the design example.
    Marked as helpful
  • Bassel || باسل•520
    @Basselfathy
    Posted 8 months ago

    Hi Wajahat.

    for the Desktop version, you can fix it like this..

    .cards{
            grid-template-columns: repeat(3, 1fr);
            grid-template-rows: auto auto;
            align-items: center;
        }
        .supervisor {
            grid-area: 1 / 1 / span 2 / span 1; 
        }
        
        .team-builder {
            grid-area: 1 / 2 / span 1 / span 1; 
        }
        
        .karma {
            grid-area: 2 / 2 / span 1 / span 1; 
        }
        
        .calculator {
            grid-area: 1 / 3 / span 2 / span 1;
        }
    

    but you will encounter farther issues because of the styles you give to the cards like margins and absolute positions, the browser inspector tool will help you find what causing the issues.

    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

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