Need help creating hover overlay

Does anyone have any idea how I can get that eye in the middle of my image? I've been trying to figure it out, but I just don't know how to approach it. I don't even know where to start but I do know that I need the pseudo class :after.
No description
17 Replies
Rägnar O'ock
Rägnar O'ock2mo ago
What did you try so far? Do you have a code snippet you can share in a codepen or jsfiddle?
Incogsnito
IncogsnitoOP2mo ago
I haven't dabbled into the css I just tried planting the html. I knew I had no idea how it worked so I just decided to ask for help I can share a github repo gimme a sec
Incogsnito
IncogsnitoOP2mo ago
GitHub
GitHub - incogsnito/nft-preview-card-component
Contribute to incogsnito/nft-preview-card-component development by creating an account on GitHub.
Incogsnito
IncogsnitoOP2mo ago
Here you go Everything including the design statuses is included. You can also point out any errors you find in my code as well.
vince
vince2mo ago
hello from reddit
Incogsnito
IncogsnitoOP2mo ago
Thank you so much! I'm trying to figure out exactly how you did it right now. I'll apply your solution once I figure out how it works.
vince
vince2mo ago
I updated with notes, feel free to ask questions
Incogsnito
IncogsnitoOP2mo ago
alright, so I tried to apply your solution but quickly ran into a problem. The icon is taking up the whole page instead of staying inside of the image.
vince
vince2mo ago
Did you add position relative to the card?
Incogsnito
IncogsnitoOP2mo ago
I put an absolute position on that section I've past that error now though. My new problem is with making it coorparate with the other image
Incogsnito
IncogsnitoOP2mo ago
alright so the problem is definitely with the positioning
No description
Incogsnito
IncogsnitoOP2mo ago
when I set it to absolute it takes up the whole page When I set it to relative it does this
vince
vince2mo ago
When you use position: absolute you need to add position: relative to the element you want the absolute to be relative to So add position: relative to the image container, and then add position absolute to the image container pseudo element. You'll need to retrofit the codepen i have slightly to your markup
Incogsnito
IncogsnitoOP2mo ago
oh my god! Thank you so much everythings working now I'll make sure to bookmark your solution. You don't know how much time you just saved me.
vince
vince2mo ago
Great, glad it works! There's a lot of different ways to do this too so I'd experiment in the future next time you need to do something like this, if you want a challenge
Incogsnito
IncogsnitoOP2mo ago
Already on it.

Did you find this page helpful?