Forum Moderators: not2easy

Message Too Old, No Replies

opacity

setting opacity of an image

         

Adam5000

10:16 pm on Jun 17, 2007 (gmt 0)

10+ Year Member



I'm trying to set the opacity of an image to 50%. I thought this was it but I guess not. Help!

<html>
<head>

<title>0pacity</title>

<style>
#photofirst {filter:alpha(opacity=50%); -moz-opacity:0.5;}
</style>

</head>

<body>

<div id="photofirst">
<img src="003.jpg">
</div>

</body>
</html>

Robin_reala

10:51 pm on Jun 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I guess you're testing in IE? The proprietary alpha filter takes values of 1 to 100, but without a % sign. I'd also recommend dropping the -moz- from the beginning of your opacity declaration. Gecko has properly supported opacity according to the spec since before Firefox 1.0, and by adding the vendor prefix you're removing the property from other UAs that implement the spec (such as Safari and Opera).

[edited by: Robin_reala at 10:51 pm (utc) on June 17, 2007]

Xapti

11:04 pm on Jun 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



yeah no percentage for IEs filter. You may want to add -khtml-opacity: as well, I believe that's for safari (and don't think it works on konqueror).

[edited by: Xapti at 11:05 pm (utc) on June 17, 2007]

Adam5000

2:29 pm on Jun 18, 2007 (gmt 0)

10+ Year Member



This is the new version but it still doesn't work in either IE 7 or firefox 2. It's probably something simple. Help!

<html>
<head>

<title>0pacity</title>

<style>
#photofirst {filter:alpha(opacity=50)}
</style>

</head>

<body>

<div id="photofirst" style="filter:alpha(opacity=50)">
<img src="003.jpg">
</div>

</body>
</html>

Adam5000

11:32 am on Jun 19, 2007 (gmt 0)

10+ Year Member



Thanks for your help Robin and X. I think I'm going to drop the fades. Crossbrowser compatability seems to be too much of an issue.

penders

1:44 pm on Jun 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I think I'm going to drop the fades. Crossbrowser compatability seems to be too much of an issue.

I didn't think it was much of an issue to get opacity working in the major browsers? Apart from the fact that filter: won't validate.

#photofirst { 
filter:alpha(opacity=50); /* IE5, IE6 */
opacity:0.5; /* FF, Opera */
}