Design comparison
SolutionDesign
Solution retrospective
Please need help with the active state for the image. Thanks
Community feedback
- @gccavalheiroPosted almost 3 years ago
Here's an example, you could create an "overlay" div after the image and its initial state would be "opacity: 0" and when the user hovers over the container where the image is, you would apply the "opacity: 1"
- HTML
<div class="card-img"> <img src="./assets/images/image-equilibrium.jpg" alt="Image Equilibrium" /> <div class="card-image-overlay"> <img src="assets/images/icon-view.svg" alt="Icon View"> </div> </div>
- CSS
.card-img { width: 100%; border-radius: 8px; overflow: hidden; line-height: 0; position: relative; } .card-img img{ object-fit: cover; } .card-image-overlay{ display: flex; align-items: center; justify-content: center; position: absolute; top: 0; bottom: 0; left: 0; right: 0; height: 100%; width: 100%; cursor: pointer; opacity: 0; background-color: hsl(178, 100%, 50%, .5); transition: .3s; } .card-image-overlay img { width: 48px; } .card-img:hover .card-image-overlay { opacity: 1; }
0@atomia11Posted over 2 years ago@gccavalheiro yes that would surely work. Thank you very much.
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