@devjhex
Posted
A suggestion regarding your code that could be of interest to you to get the hover effect on the image to work:
First of all, we need to have an element that will overlay the image element.
- To do this you may need to create a div element inside the the image container that contains the icon
<div class="nftimagecontainer">
<img
class="nftimage"
src="images/image-equilibrium.jpg"
alt="Equilibrium"
/>
<div class="imageOverlay">
<img src="/*location of the icon*/"/>
</div>
</div>
Second, we need to make the newly created div be located in the same position as the image and give it the (light blue) color.
- To do this, you need to give the new div a position of absolute and its image container a position of relative so that the new div can be put anywhere in the image container
.nftImageContainer{
position:relative;
}
.imageOverlay{
position:absolute;
background-color:/*the color you want (use rgba or hsla to give the color a little opacity e.g (rgba (0, 255, 247,0.6)*/
/*styles to make the div in the same position as the image*/
left: 0;
top: 0;
width: 100%;
height: 100%;
/*this is to give the div the same border radius as the image (to make it look the same */
border-radius: /*Same border radius as the image*/;
}
/*this should also be done to position the icon in the middle*/
.icon-view{
/*the absolute value should also be put on the icon too*/
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
/*then make the overlay disappear by adding this style to the imageOverlay styles*/
.imageOverlay{
.....
......(other styles written previously)
display:none;
}
Lastly make the imageOverlay element show when the image has been hovered over
.nftImageContainer:hover .imgOverlay{
display: block;
}
Marked as helpful
@apah-dev
Posted
@Dev-Jhex You're the best!! The way you took the time to look through the code and give a solution that doesn't affect the other parts of the code is something else. Thank you so much! I've been finding some difficulties properly understanding position and its use to stack elements on top each other. I'll have to do more research on it. I wish i could reach out to you somehow for a discussion. Great help really
@devjhex
Posted
@apah-dev You've done a great job pulling up the consistency in practicing these challenges, Well done!! We can chat more actually from here or any of the social media platforms, Check my profile on this platform so as to get my handles and again keep up with the code because you have a a great journey ahead