Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highlight images (on hover) on any background

Tags:

css

hover

image

It is quite common to want certain images to be lit up (increase brightness) when your mouse pointer hovers over them.

One technique that I know of, that works on white backgrounds is to reduce opacity on hover, which in effect increases brightness by letting more white through. The problem is obviously that it will only work on a white background.

Is there any CSS that I can add to my images that will either

a. Add a white background to the images which fits exactly, so that the same light-up effect will take place on any color background, or

b. Achieve the same effect without adding white backgrounds or using opacity at all

like image 438
Marco Prins Avatar asked May 05 '14 09:05

Marco Prins


People also ask

How do you highlight on hover?

The :hover selector is used to select elements when you mouse over them. Tip: The :hover selector can be used on all elements, not only on links. Tip: Use the :link selector to style links to unvisited pages, the :visited selector to style links to visited pages, and the :active selector to style the active link.

How do you make a background image hover?

Answer: Use the CSS background-image property You can simply use the CSS background-image property in combination with the :hover pseudo-class to replace or change the image on mouseover.


2 Answers

encapsule your image with a div

<div class="brightness">
    <img  src="test.jpg">
</div>

and apply the good css :

.brightness {
    background-color: white;
    display: inline-block;

}
.brightness img:hover {
    opacity: .5;
}

fiddle: http://jsfiddle.net/5yush/

like image 161
ekans Avatar answered Sep 21 '22 06:09

ekans


image:hover { filter: brightness(50%); }
like image 21
Kondax Design Avatar answered Sep 18 '22 06:09

Kondax Design