Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 3 years ago

Simple card styled by CSS

Hana•960
@Hanka8
A solution to the NFT preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


This was pretty challenging for me, because I couldn figure out how to place that icon over image when hover. At the end I learned something new about pseudo-elements. Any suggestions how to improve my code are welcome :)

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Pawn•320
    @CryptoPawn
    Posted over 3 years ago

    Hey! Great job with this challenge, the final product looks very good. I'd like to offer some suggestions to improve the code.

    • You have two divs with classes ´bg-1´ and ´bg-2´ which seems to be unused so they can be removed for a cleaner code.
    • I'd recommend studying Semantic HTML for better SEO optimization. In your code ´<div class="card">´ could, for example, be replaced with ´<section class="card">´.
    • For better accessibility, images should be described within the ´alt´ attribute.
    • I personally don't like ´box-shadow´ and would use ´filter: drop-shadow()´ in this situation. The filter version looks a lot smoother.
    • If you would like to center the card in exactly the middle of the website you could add following the code:
    main {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    

    To end on a more positive note. You used variables and pseudo-elements in an excellent way. Your code is easy to read, understand and is well structured. Keep it up and I hope to see more from you! :)

    Marked as helpful
  • CodeWithPedro•160
    @codewithpedro
    Posted over 3 years ago

    Hi Hanna,

    I checked your solution on git and saw the preview site and they looked really good. I had the similar problem with adding the icon over an image during the hover state. I found the solution using w3school example. But going over your code I saw how you can instead add an image with a class in background-image instead of the img source. Great job!

    https://www.w3schools.com/howto/howto_css_image_overlay.asp

    Marked as helpful
  • Shashree Samuel•8,860
    @shashreesamuel
    Posted over 3 years ago

    Hey good job completing this challenge, keep up the good work

    Your solution looks great however I think that your card needs some margin from the top using margin-top, secondly the box-shadow is supposed to be subtle hence try decreasing the value of the box-shadow a little bit.

    I hope this helps

    Cheers Happy coding 👍

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