2009
Mar
08
Opacity Setting
With CSS
Example
- .opacity {
- opacity: 0.5; /* For Newer Mozilla Browsers, Safari, and Opera */
- -moz-opacity: 0.5 /* For Older Mozilla Browsers, like Netscape Navigator */
- -khtml-opacity: 0.5; /* For Older Safari */
- -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=50)"; /* For IE 8 */
- filter: alpha(opacity=50); /* For IE 6 and IE 7 */
- }
With JavaScript
Example
- var setOpacity = function(element, value) {
- element.style.opacity = value / 100; /* For Newer Mozilla Browsers, Safari, and Opera */
- element.style.MozOpacity = value / 100; /* For Older Mozilla Browsers, like Netscape Navigator */
- element.style.KhtmlOpacity = value / 100; /* For Older Safari */
- element.style.MsFilter = '"progid:DXImageTransform.Microsoft.Alpha(opacity=' + value + ')"'; /* For IE8 */
- element.style.filter = "alpha(opacity=" + value + ")"; /* For IE 6 and IE7 */
- };
回應 (Leave a comment)