@Klonnister
Posted
Hey there! And very well done, I like your solution aside from the hover over the image problem, it looks really cool.
I'll do my best to help you out with the hover effect on the image (this is what I did):
First I created a container for:
- The NFT image.
- The curtain (that's what I called the cyan hover effect).
- The curtain icon (the little eye icon which is shown as well).
We have three elements in total.
<div class="image-div">
<img src="./images/image-equilibrium.jpg">
<div class="curtain"></div>
<img src="./images/icon-view.svg" alt="" class="curtain-icon">
</div>
- These are the properties I settled for the container (this can apply to your .image-div class):
.image-div {
width: 100%;
border-radius: 0.60rem;
overflow: hidden;
position: relative;
}
(Position relative is settled because we need to add position absolute to the curtain icon).
- I applied this css code to the NFT image:
.image-div img {
max-width: 100%;
height: auto;
display: block;
}
- Then, I added the cyan curtain as a div with background-color:
.curtain {
background-color: var(--Cyan);
width: 100%;
height: 100%;
position: absolute;
opacity: 0%;
transition: opacity 0.25s;
}
I added opacity: 0% so that when you hover over the image container (image-div), a transition will be done:
.img-div:hover .curtain {
opacity: 50%;
}
This will basically create the hover effect, the cyan div will be shown everytime you hover over the container. Read more about CSS Transitions
- Now we need to set the properties to the curtain icon which should also be shown on hover:
.curtain-icon {
position: absolute;
inset: 0;
margin: auto;
opacity: 0%;
transition: opacity 0.25s;
}
Just in case: inset: 0 is used to set the top, right, left and bottom properties to 0 (position: absolute), and margin: auto will automatically center the icon in the container.
Finally, we can set a transition for the curtain icon to show it everytime we hover:
.img-container:hover > a > .view-img {
opacity: 100%;
}
You can learn more about these efects here: W3S CSS Styling Images. Scroll down to the Image Hover Overlay section.
Hope I was helpful and happy coding!
Marked as helpful