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

CSS Flexbox, variables, media queries, overflow and more

T
Phil Daum•50
@PhillipDaum
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 am most proud of figuring out how to get the image overflow to crop off on the right side between the desktop and mobile versions, all while maintaining the rounded edges.

I did this by putting the image in a container. I applied the following CSS properties to the image's container:

.card .main-image-container {
    overflow: hidden;
    border-radius: .75rem;
}

and this to the image itself at small screen sizes:

@media (max-width: 650px) {
    .card {
        width: 20.5rem;
    }
    .card .main-image {
        max-width: 200%;
        width: 120%;
        height: auto;
      }
}

I was also able to come up with a solution to the challenge "reduce font size for smaller screens without using media queries". I discovered an interesting CSS property called 'clamp', it acts as a clamp, stopping a variable unit with a maximum and minimum size. I used it on my text-preset-02 class as shown here:

.text-preset-02 {
  font-size: clamp(.8rem, 2vw, calc(14 / 16 * 1rem)); 
  line-height: 1.5;
  letter-spacing: 0;
  font-weight: 500;
}

Next time, I would like to figure out how to import the fonts using @font-face

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

I did not figure out how to use the local font files. I tried the following syntax with @font-face and it was not working:

@font-face {
    font-family: "Figtree";
    src: url("assets/fonts/Figtree-VariableFont_wght.ttf") format("truetype");
}

My solution was to import the same font from Google fonts

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

I would like help:

  • Learning how to use @font-face
  • Better organizing my CSS classes
  • How exactly do I use the 'Spacing' section at the bottom of the Figma Design System page? How do I know what areas of the design this corresponds to?
Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

No feedback yet. Be the first to give feedback on Phil Daum's solution.

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