Posted By

JimSangwine on 05/05/11


Tagged


Versions (?)

PNG Hack/Fix for IE 6


 / Published in: CSS
 

  1. /* For CSS background-images */
  2.  
  3. .yourselector {
  4. width:200px;
  5. height:100px;
  6. background: url(/folder/yourimage.png) no-repeat;
  7. _background:none;
  8. _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/folder/yourimage.png',sizingMethod='crop');
  9. }
  10.  
  11. /*
  12. Cannot be used with repeating, needs fixed with and height.
  13. For inline HTML images */
  14.  
  15. img, .png {
  16. position: relative;
  17. behavior: expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none",
  18. this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "', sizingMethod='image')",
  19. this.src = "images/transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("','').replace('")',''),
  20. this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "', sizingMethod='crop')",
  21. this.runtimeStyle.backgroundImage = "none")),this.pngSet=true));
  22. }
  23.  
  24. /* This requires a 1x1px transparent GIF image */

Report this snippet  

You need to login to post a comment.