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

nft-preview-card-component-main

P
TAREK BARI•20
@Tarek-bari
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 find difficult in this case: when the user hover on the svg shape (eye) i can not controle the opacity of the image for reduce and display the color of background (main color) . i need to know how can i solve this problem and what is the best practice. in the end , thank you so much for challenges.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • hitmorecode•7,540
    @hitmorecode
    Posted about 2 years ago

    Thisis what you have on in your CSS --Cyan: hsl(178, 100%, 50%). If you change this to --Cyan: hsla(178, 100%, 50%, 0.5); By adding the alpha you can lower the opacity (in this case to 50%). You can adjust the alpha as you please until you find a value that you are happy with.

    Since you only want to see this on hover. Create a css rule and set the opacity to 0 to initially hide it. After that create another CSS rule to show it on hover and set the opacity to 1. This should solve your problem.

    for example: to hide

    .image { background-color: hsla(178, 100%, 50%, 0.5); opacity: 0; }

    to show on hover

    .image:hover { opacity: 1; }

    Marked as helpful
  • David Ochoa•270
    @davidochoadev
    Posted about 2 years ago

    First of all Congrats for your solution. The issue with your CSS is that you applied the opacity rule to the img element within .card .image img:hover. This rule is only triggered when the mouse hovers over the image itself, not the SVG shape (eye). As a result, even though the SVG displays correctly when hovering over the .card .image element, the image's opacity does not change as desired.

    The issue:

    .card .image img:hover {
    opacity: .5;
    }
    

    A simple solution would be to move the hover effect to the container of the img element, which is the element with the class .image. By applying the hover effect to this container and targeting the img element inside it, you can achieve the desired opacity change.

    Here's the correct CSS code:

    .card .image:hover img {
    opacity: 0.5;
    }
    

    With this modification, when you hover over the .card .image element, the img element inside it will correctly change opacity as intended. I hope I've been helpful to you, and keep up the great work!

    Best regards,

    David Ochoa. 😼

    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

Oops! 😬

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

Log in with GitHub