tags:

views:

88

answers:

2

I am using an image in background of my web page. Now when i uses a table in frontend, i want it to have some transparency effect. ? How can i do that.

.semiTransparent 
     { 
      filter: alpha(opacity = 50);
      opacity: .5;
     }

this code is not working in CSS file

+10  A: 

50% opacity IE:

filter: alpha(opacity = 50);

50% opacity other browsers:

opacity: .5;
David Hedlund
progid:DXImageTransform.Microsoft.Alpha(Opacity=xx) for IE 6 if you want to support IE6.
Zoidberg
How do I use this code in external CSS, so that it runs in all browsers.
vaibhav
including any of these will not break anything for any other browser, so you can safely specify both: `.semiTransparent { filter: alpha(opacity = 50); opacity: .5; }`
David Hedlund
thx a lot, this was very helpfull for me.
Shantanu Gupta
where should i use this code. in css file filter is not a property.Where should i use it
Shantanu Gupta
it's not a valid property, but IE will accept it. if you want certain css effects to work in IE, you sometimes have to disregard what properties actually exists in the specs
David Hedlund
+2  A: 

The problem with transparency settings in CSS, is that content/text is also semi-transparent, which makes for difficult reading.

A good "cheat" is to use a semi-transparent PNG as a background image for the div/cell. See http://blog.twipler.com for an example and an image from http://blog.twipler.com/twipler/siteimages/white-alpha-thick.png

Dead account
This is true, unless you put the background image on a separate div that sits behind all the text.
Zoidberg
That's true - but a little tricky to get the layout right (I've found).
Dead account
this may be drifting off topic, but from your comment, Quigley, i thought i might add, something that i've found immensely useful, and often neglected, is that `position: absolute` will be positioned *relative to its closest positioned parent*. So if you want to make sure two elements are on top of eachother, you can put them in a container that has `position: relative` (leaving `top` and `left` untouched, so that it stays in place), and then have both contained elements absolutely positioned to `0,0`. when used in this very controlled manner, i think absolute positioning is quite acceptable.
David Hedlund
@d but if you have a div with text of unknown lenght but fixed width, how do you set the height of the behind transparent element? Im always keen to improve my CSS.
Dead account