Question

I'm trying to get a similar effect to the one here (in this case on focus in a form field). However I want it around a small image, and to occur on hover. Obviously I can create two sprites, and in CSS replace the image with the glow image on hover, but this would not include the animation. So currently I have:

img.glow {
    -webkit-transition: all 0.5s ease; -moz-transition: all 0.5s ease; -o-transition: all 0.5s ease;
}

img.glow:hover {
    border-color: rgba(82, 168, 236, 0.8);
    outline: 0;
    outline: thin dotted \9;
    /* IE6-9 */

    -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
    -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
}

This works, but the problem is that my image has rounded corners and the glow effect occurs around the the image as a whole (i.e. it treats the image as a square, and leaves small white corners within the glow, whereas I want the glow to hug the edges of the image). The image is a transparent PNG. Is what I want to do possible?

Was it helpful?

Solution

Just add a border-radius property, so that your img element has nice round corners. The shadows will follow the shape of the element.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top