How to use CSS to resolve the normal display of PNG transparent images in IE6

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.