Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn Black Icons Grey in CSS?

Tags:

css

Wondering how these guys at http://sociali.st turn their black icons grey in their CSS ("featured with love by" section). New to this and can't figure it out.

Is their some property to allow me to change black icons to grey ones?

like image 872
Peekay Avatar asked Sep 03 '14 17:09

Peekay


People also ask

How do I GREY out a symbol in CSS?

0% (0) is default and represents the original image. 100% will make the image completely gray (used for black and white images).

How do you change an image to grayscale in CSS?

In CSS, filter property is used to convert an image into grayscale image. Filter property is mainly used to set the visual effect of an image. Example 1: In this example, use filter: grayscale(100%) to convert an image into grayscale.

How do I change the color of a logo in CSS?

We can change the color of PNG image using following CSS styles: filter: none | blur() | brightness() | contrast() | drop-shadow() | grayscale() | hue-rotate() | invert() | opacity() | saturate() | sepia() | url() | initial | inherit; The above property is used to set the visual effect of the image.


1 Answers

You can do for your own like this:

div{
  background: url(path.jpg) no-repeat;
}
div:hover{
  opacity: .4;
}

And by the way that's good to do with black images.

But if you want to change colorful image to gray then you can use like this:

div:hover{
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 3.5+ */
filter: gray; /* IE6-9 */
-webkit-filter: grayscale(100%); /* Chrome 19+ & Safari 6+ */
}

If you want to use opacity then see the code for cross-browser compatibility:

 /* IE 8 */
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";

  /* IE 5-7 */
  filter: alpha(opacity=50);

  /* Netscape */
  -moz-opacity: 0.5;

  /* Safari 1.x */
  -khtml-opacity: 0.5;

  /* Good browsers */
  opacity: 0.5;
like image 190
Bhojendra Rauniyar Avatar answered Sep 23 '22 16:09

Bhojendra Rauniyar