A long time did not write CSS, encountered a PNG transparent logo toss me a long time, also blame the previous page directly do not consider the issue of transparency. Found on the Internet several methods, useful CSS implementation, and some are using JS to realize, with JS feel overqualified, can use a pure CSS to solve the CSS bar, here thanks to the help of Blueberry Princess. The following two methods are tried, but the IE6 picture under my virtual machine is completely transparent, I do not know is not my virtual machine problem.
First save the picture as PNG-24 transparent format.
(Picture to Absolute path)
Method One: Use a PNG image as background
Pay attention to hack
HTML code
<div class= "logo" ><a href= "/" >logo</a></div>
CSS Code
. logo {width:338px; height:57px; float:left; URL (/images/logo.png) 0px 0px no-repeat!important; text-indent: -1000px; _background-image:none; Filter:progid:DXImageTransform.Microsoft.AlphaImageLoader (src=\ ' #\ ' "/images/logo.png ', senabled= ' true ', sizingmethod= ' scale '); }
Standard: _background-image:none; Filter:progid:DXImageTransform.Microsoft.AlphaImageLoader (src=\ ' #\ ' "/templets/dyimgs/wymrs/images/logo.png", Enabled= ' benabled ', sizingmethod= ' image ');
Method Two: Insert PNG image, define img
This method to prepare a completely transparent picture transparent.gif, size arbitrary.
HTML code
<div class= "logo" ><a href= "/" ></a></div >
CSS Code
. logo {width:338px; height:57px; float:left;}
. logo img {width:338px; height:57px;}
/* PNG transparent compatible IE6 */
. logo img {
Azimuth:expression (
This.pngset? This.pngset = true: (This.nodename = = "IMG" && "http://blog.51cto.com/viewpic.php?refimg=" + This.src.toLowerCase (). IndexOf ('. png ') >-1? (This.runtimeStyle.backgroundImage = "None",
This.runtimeStyle.filter = "Progid:DXImageTransform.Microsoft.AlphaImageLoader (src=\ ' #\ '"// qianduangcs.blog.51cto.com/2624849/"+" http://blog.51cto.com/viewpic.php?refimg= "+ this.src +" ', sizingmethod= ' Image ') ',
"http://blog.51cto.com/viewpic.php?refimg=" + this.src=\ ' #\ ' "/images/transparent.gif"):(THIS.ORIGBG = THIS.ORIGBG? This.origBg:this.currentStyle.backgroundImage.toString (). replace (' url (' ', ') '. Replace (') ', '),
This.runtimeStyle.filter = "Progid:DXImageTransform.Microsoft.AlphaImageLoader (src=\ ' #\ '"// qianduangcs.blog.51cto.com/2624849/"+ this.origbg +" ', sizingmethod= ' crop ') ",
This.runtimeStyle.backgroundImage = "None"), This.pngset=true
);
}
Sometimes hyperlinks add this transparent filter, and then all hyperlinks on the page <a href= "" > </a> full Point, the solution is:
Give a plus position:relative;
But here's to remind you that your image path here is a relative path, so it's worth noting that the relative path is relative to the HTML, not the CSS.