转自:http://www.loveyuki.com/Article/CSS_Image_Autosize_IE_Firefox.aspx

一直以来有个很头疼的问题困扰着我,那就是图片缩放的问题,写到 JS 里面吧,不太容易修改。写到 CSS 里面吧,IE 6 又不支持 max-width,今天用了很久时间终于解决了这个问题,基本完美了,唯一不完美的就是 IE 6 只有在图片完全下载完成后才会自动调整大小,不过聊胜于无,总比进入页面后看到长长的横向滚动条舒服的多,这里使用了 expression,但是利用了一次加载,所以 expression 不会造成内存泄漏。当然,如果你有更好的解决方案,希望能与我交流。代码如下:

.Image {
    max-width:600px;
    height:auto;
    cursor:pointer;
    border:1px dashed #4E6973;
    padding: 3px;
    zoom:expression( function(elm) {
         if (elm.width>560) {
              var oldVW = elm.width; elm.width=560;
              elm.height = elm.height*(560 /oldVW);
         }
         elm.style.zoom = ‘1′;
     }(this));
}
相关文章:

December 24th, 2007区分IE6,IE7,FireFox的CSS

区别IE6FF

CSS代码
  1. background:orange;*background:blue;  
区别IE6IE7
  

CSS代码
  1. background:green !important;background:blue;  
区别IE7FF
CSS代码
  1. background:orange; *background:green;  

区别FFIE7IE6

CSS代码
  1. background:orange;*background:green !important;*background:blue;  
注:IE都能识别*,标准浏览器(如FF)不能识别*
  IE6能识别*,但不能识别!important
  IE7能识别*,也能识别!important
  FF不能识别*,但能识别!important
 

 

IE6

IE7

FF

*

×

!important

×

另外再补充一个,下划线"_",
IE6支持下划线,IE7和firefox均不支持下划线。(推荐)

于是大家还可以这样来区分IE6IE7FireFox

CSS代码
  1. background:orange;*background:green;_background:blue;  

注:不管是什么方法,书写的顺序都是FireFox的写在前面,IE7的写在中间,IE6的写在最后面。

相关文章:

© 2008 JorWang | iKon Wordpress Theme |