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

NFT Card challenge using flex box

Martha Eason•30
@marthaeason
A solution to the NFT preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Any advice is appreciated, especially with my flex-box as it is one of my first experiments learning this!

I can't figure out how to get the NFT Card image to change its state for :hover. - any tips on accomplishing this? I tried overlaying the aqua background color with opacity and z-index but that didn't work. Thank you!

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Heli0s•670
    @zeerobit
    Posted over 3 years ago

    Hi Martha, here are a few pointers:

    • You don't necessarily need to wrap the equilibrium image in 2 divs instead use one of the divs to also wrap the icon-view image. Here is an example:
    <div class="img__container">
            <a href="#">
              <img src="images/image-equilibrium.jpg" class="eq__img" alt="" aria-hidden="true" />
            </a>
            <div class="overlay">
              <a href="#"><img src="images/icon-view.svg" alt="" aria-hidden="true" / class="icon-view"></a>
            </div>
    </div>
    
    • In order to get the hover effect, add position relative to the image-container and on the overlay use position absolute so you can place the overlay on top of the image-container, convert the hsl background color to rgb [rgb(0, 255, 247, 0.4);] which lets you add the opacity for the transparency color effect, use flexbox to center the icon-view image then add opacity: 0; to hide the overlay. Then add opacity: 1; on hover so the overlay appears when you hover
    .overlay:hover {
      opacity: 1;
      cursor: pointer;
    }
    
    • ETH is missing the 0.041 in the front
    • The creator part can be wrapped in figure, figcaption instead of div for better semantics
    • Use rem instead of px since it's not scalable
    • Remove the height from .NFT-card, let the content dictates the height and use max-width instead of width
    • You don't need to add width: 275px on each section to prevent them from touching the edges, simply add a padding on the container to achieve that
    • For images you just need to add max-width: 100%; and display: block; and not a set width and height
    • I'd suggest you to add a css reset in your stylesheet to avoid any weird browser behaviors, i use this css reset

    Hope these help, Happy coding !!!

    Marked as helpful
  • shahidafridi23•350
    @shahidafridi23
    Posted over 3 years ago

    Hi @marthaeason , you did a good job on this challenge, for hover state add HTML and style before, with opacity 0 and then add hover state with opacity 1, hopefully, this will work.

    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

Oops! 😬

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

Log in with GitHub