I'm looking for a method that would allow a div
or span
element to appear over a image when you :hover
over that image. I'm able to do this using the .image:hover ~ .overlay
, but it's not exactly what I'm looking for. The div
or span
element needs to take the dimensions of the images, since there will be multiple sizes.
Example
<img width="200" height="200"/>
would allow you to :hover
changing the div
or span
element from display: none
to display: block
(doesn't necessarily need to be a block). The element that's being changed from invisible to visible would have to automatically detect the size of the image and match the size of the element to these same dimensions (200x200). However, I could also have a <img width="300" height="400"/>
that would need the element to match the size (300x400).
I'm also looking for a super easy way for these elements to be positioned perfectly over the images.
Here's my code pen to show what I've got so far.