Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

nft-preview-card

Tee-Ds 80

@Tee-Ds

Desktop design screenshot for the NFT preview card component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


Please can anyone help me with the active state of the Equilibrium image coz I've tried almost everything in my capacity and the active state just isn't working I've tried hover z-index ::before and ::after pseudo elements but they don't seem to work

Community feedback

Bryan Li 3,550

@Zy8712

Posted

In order to add the active hover state you need to add a "curtain" over your image for it to work. What I did was something along the lines of:

For the HTML:

<div class="image-div">
   <img src="./images/image-equilibrium.jpg">
   <div class="curtain"></div>
   <img src="./images/icon-view.svg" alt="" class="curtain-icon">
</div>

For the CSS:

.image-div img {
   max-width: 100%;
   height: auto;
   display: block;
}

.curtain {
   background-color: var(--Cyan);
   width: 100%;
   height: 100%;
   position: absolute;
   opacity: 0%;
   transition: opacity 0.25s;
}

.img-div:hover .curtain {
   opacity: 50%;
}

.curtain-icon {
   position: absolute;
   inset: 0;
   margin: auto;
   opacity: 0%;
   transition: opacity 0.25s;
}

.img-container:hover > a > .view-img {
   opacity: 100%;
}

This is mainly done using the :hover effect. Most of this css is just setting up the curtain's appearance. Hope you find this useful 👍

Marked as helpful

0

Tee-Ds 80

@Tee-Ds

Posted

@Zy8712 Thanks a lot Figured out the problem with my code was u was trying to use diplay:none; and visibility:hidden; rather than opacity:0;

0

Please log in to post a comment

Log in with GitHub
Discord logo

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