CSS按比例縮放圖片

來源:互聯網
上載者:User

FF , OPERA , SAFARI , IE7 , IE8 方法如下:

 

img{max-width:100px;max-height:100px;}
img{min-width:100px;min-height:100px;}

 

 

IE6及其以下版本的瀏覽器,利用其支援的expression屬性:

 

* html img { /* for IE6 */
width: expression(this.width > 100 && this.width > this.height ? 100 : auto);
height: expression(this.height > 100 ? 100 : auto);
}

 

auto 會造成IE6錯誤,如: 文字不能被選中,輸入框得不到焦點。

故把 auto  改成 true

 

 

* html img { /* for IE6 */
width: expression(this.width > 100 && this.width > this.height ? 100 : true);
height: expression(this.height > 100 ? 100 : true);
}

 

相關文章

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.