Design comparison
Solution retrospective
I had problem with hidding and showing the view icon on hover with the use of css, I tried z-index and even opacity but it did not work well as expected . i will b e greatfull if someone can help me out with this.
Community feedback
- @HassiaiPosted over 1 year ago
For the hover effect of image wrap the img tag in a div, within that div wrap the icon view in a div.
<div class=" equil-image"><img class="img"><div class= "overlay"><img></div> </div>
in the css, give .equil-image a width of 100% and position: relative , give .img a width of 100% and display: block. give .overlay position: absolute, right, left, bottom, top, of 0 background-color of cyan and opacity of 0. Give img:hover .overlay opacity of 0.9 and a pointer value of cursor.
.equil-image{ width:100%; position: relative; } .img{ width:100%; height:100%; } .overlay{ position: absolute; top:0; left:0; bottom: 0; right: 0; background-color: hsl(); opacity: 0; } .img:hover .overlay{ opacity:0.9; cursor: pointer; }
To center .icon on the image.:
.overlay img{ position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
Hope am helpful.
Well done for completing this challenge. HAPPY CODING
Marked as helpful0
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