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

frontend mentor nft preview

tailwind-css
Limbert Lino Mattos•40
@linomattos
A solution to the NFT preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


I made the project with tailwind CSS. With the help of the perfect pixel extension.

I have problems with the active state of the hover image. I can convert the color of the image but the eye icon has lower opacity.

Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

  • Coder Suresh•870
    @coderSuresh
    Posted almost 2 years ago

    Hey there, excellent work.

    I didn't know anything like the Pixel Perfect extension existed. Thanks for this.

    I have created a pull request on your repo to solve your issue with the hover state overlay and icon. You can find it here: https://github.com/retronauta/frontend-mentor-nft-preview/pull/1

    Alternatively, you can look through my solution here: https://github.com/coderSuresh/nft-preview-card

    And, if you don't feel like going through links, here is a general idea of how I did it.

    index.html

            - use img_container class
            - use custom css to display overlay on hover (in input.css)
        -->
          <div
            class="img_container relative flex cursor-pointer justify-center items-center h-fit my-6"
          >
    
          <!-- 
            - making overlay with view icon 
            - bg-transparent-cyan is a custom color from tailwind.config.js 
            - that gets its value from css variable in input.css
          -->
            <div
              class="overlay absolute pointer-events-none top-0 hidden left-0 w-full h-full bg-transparent-cyan rounded-xl"
            >
              <div
                class="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2"
              >
                <img
                  src="./images/icon-view.svg"
                  alt="view icon"
                  class="w-12"
                />
              </div>
          </div>
    
          <!-- 
            - we don't need any pointer events on this image 
            - using pointer-events-none class
          -->
            <img
              src="./images/image-equilibrium.jpg"
              alt="Nft picture"
              class="rounded-xl pointer-events-none"
            />
          </div>
    

    input.css

    :root {
        --transparent-cyan: hsla(178, 100%, 50%, 0.50);
    }
    
    /* make image overlay visible on hovering its parent div */
    .img_container:hover .overlay {
        display: block;
    } 
    

    tailwind.config.js

    module.exports = {
      content: ['./dist/*.{html, js}'],
      theme: {
        extend: {
          colors: {
            ....
            'transparent-cyan': 'var(--transparent-cyan)' //from css variable (to be used in html)
          },
          fontFamily: {
            outfit: ['Outfit'],
          },
        },
      },
      plugins: [],
    }
    
    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 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