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 using Adjacent-Sibling Selector

@braien-machado

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


Is there a simpler way to change opacity of the nft image when hovering the view icon with only HTML and CSS or the Adjacent-Sibling Selector solution is the best?

Community feedback

Byron 2,180

@byronbyron

Posted

Hi @braien-machado

You can put a hover on the img-container to show the eye icon and cyan background as a pseudo element. Something like...

<div class="img-container">
    <img src="./images/image-equilibrium.jpg" alt="equilibrium" class="card-img">
</div>
.img-container {
    position relative;
}

.img-container::before {
    content: '';
    background: url('./image/icon-view.svg') center no-repeat hsla(178, 100%, 50%, 0.5);
    display: block;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.3s, opacity 0.3s;
}

.img-container:hover::before {
    visibility: visible;
    opacity: 1;
}

Here's a similar example

Hope that helps 👍

Marked as helpful

1

@braien-machado

Posted

@byronbyron , thanks for the reply! I'm not used to pseudo elements, so it's great to see this way to solve my problem.

0
Byron 2,180

@byronbyron

Posted

@braien-machado Happy to help, dude!

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