Page 1 of 1
opacity
Posted: Mon Mar 03, 2008 4:32 pm
by sorin21us
I know that this forum is for PHP, but maybe someone knows how to make in java script the code for an image opacity. I want that because if I put the opacity with css
#image
{
opacity: 0.30;
}
doesn't work in IE and Firefox, and I know that you can do that with java script, but I don't know how.
Re: opacity
Posted: Tue Mar 04, 2008 3:25 am
by onion2k
There's a lot of CSS 3 things that browsers can't do. I imagine opacity is one of them.
Re: opacity
Posted: Tue Mar 04, 2008 8:04 am
by Zoxive
Opacity is Actually CSS2.
http://www.quirksmode.org/css/opacity.html
http://www.mandarindesign.com/opacity.html
Code: Select all
<div id="test"></div>
<style type="text/css">
#test{
background-color:red;
width:100px;
height:100px;
opacity:.30;
}
</style>
Re: opacity
Posted: Tue Mar 04, 2008 9:54 am
by pickle
sorin21us wrote:I know that this forum is for PHP
That's why we have a Client-Side forum. I'm moving the thread there.
Re: opacity
Posted: Tue Mar 04, 2008 9:55 am
by sorin21us
Mod | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Thank you for the answers.
I was looking for something like this:
/*--- The code in js for opacity to works with filter IE and with opacity Firefox----*/
Code: Select all
function setOpacity(value) {
document.getElementById("mage").style.opacity = value/10;
document.getElementById("image").style.filter = 'alpha(opacity=' + value*10 + ')';
}
/*--The oapacity with CSS2 works only for Firefox---*/
Mod | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Re: opacity
Posted: Tue Mar 04, 2008 10:40 am
by pickle
IE doesn't support standards-based opacity (or at least IE6 didn't). You'll need to play around with the filter property. Google likely has something to say about the subject too.