Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 1 year ago

Blog Preview Card

sass/scss, vite
Erratic Enigma•200
@erratic-enigma
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 wanted the drop shadow of the card to react to the state of the child a element (i.e.: when a user hovers and focuses on the link, the drop shadow changes as well). This was a perfect time to try out the new :has() pseudo-class, used to select the card (.blog-preview) when the child a element (.link-wrap) is interacted with.

.blog-preview:has(.link-wrap.-overlay:is(:focus, :hover, :active)) { … }
What challenges did you encounter, and how did you overcome them?

Because the illustration was a vector graphic, I opted to use an svg element to display it. However, the object-fit property, useful for cropping images, doesn't appear to work with svg elements. Thankfully, an svg attribute called preserveAspectRatio provides similar results as object-fit. This article goes into more detail about it.

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

_

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 Erratic Enigma'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
  • Use cases

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