开发者

Is there any cross-browser javascript library to set and get opacity?

开发者 https://www.devze.com 2023-02-07 07:02 出处:网络
#a_div { background: rgba(200, 54, 54, 0.5); // IE background:transparent; filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000050,endColorstr=#99000050);
#a_div {
   background: rgba(200, 54, 54, 0.5);
   // IE 
    background:transparent;
   filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000050,endColorstr=#99000050);
   zoom: 1;
}

Is there any 开发者_JS百科javascript library I can use to get and set opacity to html element. Need handle Cross-browser problem.


JQuery - crossbrowser JS framework?

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


I always apply these 5 CSS elements, then you're safe in most browsers.

opacity: .75; /* Standard: FF gt 1.5, Opera, Safari */
filter: alpha(opacity=75); /* IE lt 8 */
-ms-filter: "alpha(opacity=75)"; /* IE 8 */
-khtml-opacity: .75; /* Safari 1.x */
-moz-opacity: .75; /* FF lt 1.5, Netscape */


Use the Prototype Javascript library.

HTML:

<div id="something">Hello</div>

JS

$('something').setOpacity(0.5);
0

精彩评论

暂无评论...
验证码 换一张
取 消