Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make white background of image transparent in css

Tags:

html

css

I have two images, one of which is a small icon that is superimposed over the first image. My icon has a white background, so when the icon is placed over the other image, we get this effect where a white square appears over the image. Ideally, I do not want to display this white background on top of my other image. Is there is a CSS property I can apply to my icon to make its white background transparent?

like image 219
Nick Avatar asked Sep 30 '12 16:09

Nick


People also ask

How do I make a white background transparent in CSS?

Example explained First, we create a <div> element (class="background") with a background image, and a border. Then we create another <div> (class="transbox") inside the first <div>. The <div class="transbox"> have a background color, and a border - the div is transparent.

How do I make the background of an image transparent in CSS?

To set the opacity of a background, image, text, or other element, you can use the CSS opacity property. Values for this property range from 0 to 1. If you set the property to 0, the styled element will be completely transparent (ie. invisible).

Can I fade a background image in CSS?

There's no CSS property that you can use to change the opacity of only the background image. Unlike background colors, which allow you to adjust the alpha channel to control opacity, it simply doesn't exist for the background-image property.


1 Answers

Actually there is a way although only currently supported on Chrome, Firefox, and Safari. If the background color is white, you can add the CSS property:

mix-blend-mode: multiply; 

You can read more about it here: https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode

like image 98
user1822264 Avatar answered Sep 28 '22 09:09

user1822264