IE6下png图片背景透明的方法
这个方🤮法开发😍项目的【xiàng mù de】时候一直在用,简单的🌽两步就【liǎng bù jiù】可以使用了【yòng le】。
首先在【shǒu xiān zài】<head>与</head>之间加【zhī jiān jiā】👁入下面➿的代码:
<!--[if IE 6]>
<script src="png.js"></script>
<script>
DD_belatedPNG.fix('.png_bg,img,.b');
</script>
<![endif]-->
其中【qí zhōng】Ⓜpng.js的完整【de wán zhěng】🕶代码如下:
/**
* DD_belatedPNG: Adds IE6 support: PNG images for CSS background-image and HTML <IMG/>.
* Author: Drew Diller
* Example usage:
* DD_belatedPNG.fix('.png_bg'); // argument is a CSS selector
* DD_belatedPNG.fixPng( someNode ); // argument is an HTMLDomElement
**/
eval(function(p,a,c,k,e,r)e=function(c){return(c<a?'';if(!''.replace(/^/,String))while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('2 E={J,1E:7()4(x.1l&&!x.1l[6.J]){x.1l.23(6.J,\'244(1F.11)1F.11(\'28\',7(){E=29})}},1G\');b.1c(6.J+\'\\\\:9\',\'Q:1p;\');b.1c(\'1J.\'+6.J+\'1K\',\'12:y; 1q:y; Q:1p; z-2c:-1; 1d:-1r; 1L:1M;\');6.1o=b},1N:7()2 a=13.2d;4(13.1e.K(\'2e\')!=-1||13.1e.K(\'1q\')!=-1){E.1f(a)}4(13.1e==\'8.1s\'){2 b=(a.F.1s==\'y\')?\'y\'}4(13.1e.K(\'14\')!=-1)E.1t(a)}},1t},15:7(a)2k(7(){E.1f(a)},1)},2l},1f:7(a)a.S.1Q=\'\';6.1R(a);6.16(a);6.1t(a);4(a.O){6.1S(a)}},1T;4(b.17==\'A\')2 e={2q;G(2 a M e)d[a]=e[a]}}G(2 h M d){b.11(\'1w\'+h,7(){c[d[h]](b)})}b.11(\'2u\',6.1N)},1x},1S:7(a)2 b={\'2y\';G(2 s M b)a.3.N.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;4(a.17==\'35\')4(a.1h.21().K(/\\.22$/)!=-1){a.O=P;a.8.1L=\'1M\'}U{1g}}U 4(a.F.19.21().K(\'.22\')==-1){1g}2 b=E;a.3={N,C:}};2 c={9,I:}};G(2 r M a.3){G(2 e M c){2 d=b.J+\'a.3[r].9.36=V;a.3[r].9.37(a.3[r].I);a.38.1n(a.3[r].9,a)}a.3.C.9.39=\'y\';a.3.C.I.3a=\'3b\';a.3.N.I.1w=V;b.1T(a);b.1x(a);b.1x(a.3c);b.1f(a)}};3d{x.3e("3f",V,P)}3g(r){}E.1E();E.1G();',62,203,'||var|vml|if||this|function|style|shape|||||||||||||||||||||px|||document|none||||image|vmlBg|DD_belatedPNG|currentStyle|for||fill|ns|search||in|color|isImg|true|position||runtimeStyle||else|false||||imgSize||attachEvent|behavior|event|filter|handlePseudoHover|vmlOffsets|nodeName|backgroundColor|backgroundImage|case|firstChild|addRule|top|propertyName|applyVML|return|src|width|height|bLW|namespaces|createElement|insertBefore|styleSheet|absolute|border|10000px|display|vmlOpacity|parseInt|lastIndexOf|on|giveLayout|left|bTW|break|b1|b2|repeat|createVmlNameSpace|window|createVmlStyleSheet|documentElement|default|img|_sizeFinder|visibility|hidden|readPropertyChange|split|fixPng|cssText|vmlFill|copyImageBorders|attachHandlers|zIndex|transparent|removeAttribute|body|0l|clip|rect|toLowerCase|png|add|urn|schemas|microsoft|com|onbeforeunload|null|url|VML|index|srcElement|background|block|lpha|substring|100|opacity|setTimeout|fix|length|expression|resize|move|mouseleave|mouseenter|focus|blur|onpropertychange|zoom|static|relative|borderStyle|borderWidth|borderColor|substr|className|onload|offsetWidth|offsetHeight|clientWidth|clientHeight|offsetLeft|offsetTop|clientLeft|clientTop|coordsize|coordorigin|path|m0|l0|xe|switch|center|right|bottom|01|Math|ceil|backgroundPosition|backgroundRepeat|toUpperCase|BODY|TD|TR|IMG|stroked|appendChild|parentNode|fillcolor|type|tile|offsetParent|try|execCommand|BackgroundImageCache|catch'.split('|'),0,{}))
然后在🔸需要使【xū yào shǐ】PNG透明的【tòu míng de】html代码中🆒调用下面的代【miàn de dài】码🧚:
class="png_bg"
关键词:IE6,png,图片背景透明
阅读本文后您有什么感想? 已有 人给出评价!
- 1
- 1
- 1
- 1
- 1
- 1