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

Responsive article with links to trigger

Daniele Ercoli•170
@DanieleErcoli243
A solution to the Article preview component 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'm proud because I managed to do the project all by myself. Next time I will watch everything that can help me finding issues and solutions.

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

The size of the picture changed from the smaller sizes to the big one and it took a while to see the the figure tag needed to be resized. I use the console to see it. Then I had a little trouble to close the box with the link and I overcame it refreshing the browser.

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

It was easy, I don't think I would need help.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • gauravk2203•310
    @gauravk2203
    Posted 7 months ago

    Suggestions for Improvement:

    Use CSS Variables for Colors and Spacing:

    Define CSS variables for colors, font sizes, and spacing at the root level. This avoids repetition and makes the design easier to update.

    :root {
        --background-color: hsl(210, 46%, 95%);
        --text-color-primary: hsl(217, 19%, 35%);
        --text-color-secondary: hsl(214, 17%, 51%);
        --card-radius: 10px;
        --spacing-small: 10px;
        --spacing-medium: 20px;
    }
    

    Then use them:

    body {
        background-color: var(--background-color);
    }
    

    Avoid Deep Nesting:

    Deeply nested selectors like .card .card-body h1 can be harder to maintain and may lead to specificity issues. Try to keep selectors simpler and use class names to target elements.

    .card-title {
        font-size: 16px;
        color: var(--text-color-primary);
    }
    

    Improve Responsiveness:

    Consider using relative units (like em, rem, %, or vw) instead of fixed units (like px) for margins, paddings, and font sizes to make the layout more fluid.

    Optimize Repeated Values:

    If the same property-value pairs (e.g., padding or border-radius) are repeated, move them to a shared class or parent container.

    Avoid Fixed Heights:

    You mentioned fixed height for the container is an issue. Replace fixed heights with min-height or let the height adjust dynamically. Use fit-content for Dynamic Layouts:

    For the #share section, consider width: fit-content for dynamic sizing instead of hardcoding widths.

    Add Comments for Clarity:

    While your code is structured, adding comments for specific sections can clarify the intent, especially for larger projects.

    Group Media Queries:

    Instead of repeating the same media query for different selectors, group them together for easier maintenance.

    @media screen and (min-width: 768px) {
        .container {
            max-width: 600px;
        }
        .card-title {
            font-size: 18px;
        }
    }
    

    Example Refactor: Here’s how the body and container styles might look with these improvements:

    :root {
        --background-color: hsl(210, 46%, 95%);
        --text-color-primary: hsl(217, 19%, 35%);
        --text-color-secondary: hsl(214, 17%, 51%);
        --card-radius: 10px;
        --spacing-small: 10px;
        --spacing-medium: 20px;
        --max-width: 320px;
    }
    
    body {
        background-color: var(--background-color);
        font-family: 'Manrope', serif;
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }
    
    .container {
        max-width: var(--max-width);
        margin: 0 auto;
        padding: var(--spacing-medium) 0;
    }
    
    img {
        max-width: 100%;
        height: auto;
    }
    

    Final Notes: Your approach is solid, and with a few tweaks, it will be even more professional and maintainable. Using tools like Prettier for formatting or a CSS preprocessor like SCSS can also help streamline your development process.

    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