Design comparison
Solution retrospective
Hola Frontend Mentor community,
I would be delighted if you regard how I made the elements change their appearance on hover. I used a few:
.container: hover>.item {}
and wonder if there's a better alternative.
It's the third challenge I completed, and that's the one I think the design is more interesting.
Best regards from Curitiba, Brazil 🇧🇷
Community feedback
- @KuraanalPosted over 1 year ago
there is many way to make the overlay. Best is very subjective..
One could be a container like this with the overlay opacity set to 0 and change to 0.5 on hover (Same for the view icon):
<div class="card__image"> <img src="./assets/images/image-equilibrium.jpg" alt="NFT preview" /> <div class="image__overlay"></div> <img src="assets/images/icon-view.svg" class="overlay__icon" alt="" /> </div>
.image__overlay { position: absolute; inset: 0 0 0 0; background-color: var(--your-clr); }
Or you can just pout the image like this, and use the CSS pseudo element ::before and ::after to make the overlay.
<div class="card__image"> <img src="./assets/images/image-equilibrium.jpg" alt="NFT preview" /> </div>
.card__image::after, .card__image::before { position: absolute; opacity: 0; } .card__image::before { content: ''; inset: 0 0 0 0; background-color: var(--overlay-clr); } .card__image::after { content: url(../images/icon-view.svg); top: 50%; left: 50%; transform: translate(-50%, -50%); } .card__image:hover::before, .card__image:hover::after { opacity: 0.5; }
Marked as helpful0@brunomoletaPosted over 1 year ago@Kuraanal Thanks for explaining the pseudo element :)
0
Please log in to post a comment
Log in with GitHubJoin 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