Here's the HTML code I am working with:
<article>
<picture>
<img src="a.png">
</picture>
</article
This particular HTML code is used throughout my page, where the image has a varying width. The goal is to create an image hover overlay when hovering on the image, displaying a "+" sign on it. I attempted to achieve this using the following CSS:
article picture { position: relative; }
article picture:before { background: rgba(0,0,0,.75); content: "+"; height: 100%; opacity: 0; position: absolute; transition: opacity .25s ease; width: 100%; }
article picture:hover:before { opacity: 0.9; }
While it works to some extent, I'm facing a couple of issues. The overlay is slightly larger than the image, about 10 pixels. How can I adjust this? Additionally, I want to center the "+" symbol on my image, but traditional methods like vertical-align: middle
and line-height
are not feasible due to the variable size of the image. Any suggestions?