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

Blog preview card challenge.

P
Carlos Santana•260
@cacesasa
A solution to the Blog preview card 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 most proud of the way I was able to incorporate the .svg file in my solution because this was the firts time using it as a background image, something that I thought was not posible. Next time I will try to not use absolute values to create the design.

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

Trying to incorparate the .svg file in the solution was a challenge for me, first I try to use it as an inline component in my HTML but when I tried to round the borders with css I realized it was not posible, and I started to look for a different solution to my problem, until I found out that I could use the image as a backgound image.

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

I will love for some imput on how to make my code more compact. I think that I'm using too many lines of code to get to a solution.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • P
    Sergei Borja•1,130
    @wonderlust101
    Posted 12 months ago

    What I notice is that you have some code that is either redundant or unnecessary. Fixing or removing those parts of your css will shorten your code significantly.

    For example, in this section , you don't need to put both max and min width/height when simply putting height and width will do. In addition, you grid will naturally fill the available horizontal space so you won't need width.

    Before:

    .card_wrapper{
        min-width: 100vw; // From this
        max-width: 100vw; // From this
        min-height: 100vh; // From this
        max-height: 100vh; // From this
        display: grid;
        justify-content: center;
        align-items: center;
    }
    

    After:

    .card_wrapper{
        height: 100vh;  // To this
        display: grid;
        justify-content: center;
        align-items: center;
    }
    

    Here you can just keep the width, the container will hug the height of the contents in the container.

    Before:

    .card {
        background: var(--primary-color-white);
        display: grid;
        min-width: 327px; //  From this
        max-width: 327px; //  From this
        min-height: 501px; //  From this
        max-height: 501px; //  From this
        border-radius: 20px;
        border: 1px solid black;
        box-shadow: 8px 8px 0px 0px rgba(0,0,0,1);
        padding: 24px;
    }
    

    After:

    .card {
        background: var(--primary-color-white);
        display: grid;
        width: 327px; //  To this
        border-radius: 20px;
        border: 1px solid black;
        box-shadow: 8px 8px 0px 0px rgba(0,0,0,1);
        padding: 24px;
    }
    

    Once you clean this up, the four lines of code setting height and width will turn to one or two lines of code. This is not every but hopefully this gives you a clear idea on what you need to fix.

    Have fun coding 😊.

    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