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

NFT preview card component

styled-components
Agnar•220
@agnar-nomad
A solution to the NFT preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


All feedback appreciated.

I think I finally understand ::after and ::before and I have learnt to do image overlays in this project. It was fairly easy after struggling with the previous tasks.

Code
Couldn’t fetch repository

Please log in to post a comment

Log in with GitHub

Community feedback

  • Andreas Remdt•950
    @andreasremdt
    Posted over 2 years ago

    Hey @agnar-nomad,

    Nice job on the challenge! It looks so close to the design, great work! ::before and ::after can be tricky to understand, keep going and these things will become easier. :-)

    Some ideas to improve your code:

    • Your title "Equilibrium #3429" uses an h3 element, but since it's the first (and only) heading on the page it makes more sense to use an h1 instead. That's also the only remark on your accessibility report. Page headings should always start at the highest (h1) and incrementally go down until the lowest (h6).
    • You don't need to use both pseudo-classes, you can achieve the same result with just one (either ::before or ::after, it doesn't matter).
    .nft-container::before {
      content: "";
      position: absolute; 
      inset: 0;
      background: var(--cyan) url(images/icon-view.svg) center no-repeat;
      opacity: 0;
    }
    

    The above code achieves the same but is quite simplified:

    • You can combine background-color, background-image, background-position, etc. into a single shorthand property called background.
    • inset: 0 is a shorthand for top: 0; left: 0; bottom: 0; right: 0. It just saves time and lines of code :-)
    • Also, by using inset: 0, you don't need width and height as the element will stretch all the way.
    • content should be an empty string, since you set the background image via the background property.

    Additionally, I wouldn't use an ul element for the Ethereum price, since semantically it doesn't make the most sense. A simple div or p should do the job as well and is semantically more correct.

    I hope my feedback helped you, let me know if you have any questions :-)

    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
Frontend Mentor logo

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 1st-party linked stylesheets, and styles within <style> tags.

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.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub