I would like to render a border over an image on mouseover, but accomplish it solely with CSS.
My structure is very simple:
<div class="outer">
<div class="overlay"></div>
<img />
</div>
The idea is that .overlay
gets a 5px border and becomes visible when the mouse hovers over .outer
The image can be of any width / height - it is not known and cannot be specified exclusively.
The only problem is that due to box-model laws i end up with the right and bottom border being rendered outside of .outer
because 100% width / height
on .overlay
already cover the full width of outer
.
In order to fully understand what i am trying to explain, please refer to my jsFiddle.
How can i make .overlay
be exactly as wide and high as required in order to display the border fully above my image? I am looking for a cross-browser compatible solution, so modifying box-model behaviour for the problematic element does not appear to be an option.