Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS background opacity with rgba not working in IE 8

I am using this CSS for background opacity of a <div>:

background: rgba(255, 255, 255, 0.3); 

It’s working fine in Firefox, but not in IE 8. How do I make it work?

like image 268
Moon Avatar asked Oct 20 '10 07:10

Moon


People also ask

Does opacity work in IE?

Note: Alpha filters in IE accept values from 0 to 100 . The value 0 makes the element completely transparent (i.e. 100% transparent), whereas the value 100 makes the element completely opaque (i.e. 0% transparent).

How do I make a background transparent in rgba CSS?

background-color: transparent; But if you want it to be in colors, you can use: background-color: rgba(255, 0, 0, 0.4); Or define a background image ( 1px by 1px ) saved with the right alpha .

How do you add opacity in rgba?

RGBA is a color format, basically containing values for red, green, blue respectively and 'A' in RGBA stands for Alpha. To set the opacity of color we mainly change the value of alpha. The value of alpha varies from 0.0 (fully transparent) to 1.0 (fully opaque).


2 Answers

To simulate RGBA and HSLA background in IE, you can use a gradient filter, with the same start and end color (alpha channel is the first pair in the value of HEX)

background: rgba(255, 255, 255, 0.3); /* browsers */ filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#4cffffff', endColorstr='#4cffffff'); /* IE */ 
like image 136
diablero13 Avatar answered Sep 26 '22 21:09

diablero13


Create a png which is larger than 1x1 pixel (thanks thirtydot), and which matches the transparency of your background.

EDIT : to fall back for IE6+ support, you can specify bkgd chunk for the png, this is a color which will replace the true alpha transparency if it is not supported. You can fix it with gimp eg.

like image 28
MatTheCat Avatar answered Sep 24 '22 21:09

MatTheCat