PDA

View Full Version : Is there a simple way of making DIV's opaque?



Jay Dog
01-08-2014, 08:51 AM
Hi,

Is there a simple way of making DIV's opaque?

Thanks, Jay Dog

djr33
01-08-2014, 08:54 AM
Opaque = visible, "normal".
Do you mean transparent, see-through?
Opacity is a measure of visibility-- 100% is normal, visible, and 0% is fully transparent.

https://www.google.com/search?q=css+div+opacity
Of course css+div+transparency would come up with various results also.

Let us know if you have a more specific question, but this is one that should be answerable with a simple search.

jscheuer1
01-08-2014, 02:38 PM
All current version browsers use a division's css opacity property to set its opacity. However, users of Win XP who cannot avail themselves of the latest version of IE and who do not chose another browser like Chrome, Firefox, etc. are stuck with IE 8 which doesn't work with the opacity css property. So you can either exclude those folks from the opacity effects you want to use on your page or use a javascript library like jQuery which normalizes things like that, making IE 8 and less respond to the css property opacity if it's applied via one of jQuery's css methods.

How to (assuming a div with an id of "myDiv", and setting opacity to half) -

Using just css and not worrying about IE 8 and less:


#myDiv {opacity: 0.5;}

The same thing, only applied dynamically via ordinary javascript:


documentGetElementById('myDiv').style.opacity = 0.5;

Now, using jQuery (which does virtually all browsers):


$('#myDiv').css({opacity: 0.5});



You can use IE 8 and less' proprietary filter alpha in a css declaration and/or javascript to cover those browsers (various conventions must be followed to make sure this doesn't interfere with normal browsers), but you asked for simple, and that's not simple.