一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

四款css 图片按比例缩放实例(兼容ie6,7,firefox)

时间:2010-09-22 编辑:简简单单 来源:一聚教程网

使用max-width,max-height;或者min-width,min-height的css属性即可。如:

 代码如下 复制代码
img{max-width:100px;max-height:100px;}
img{min-width:100px;min-height:100px;}


对于ie6及其以下版本的浏览器,则可以利用其支持的expression属性,在css code中嵌入网页特效 code
来实现图片的缩放

.thumbimage {max-max-} /* for firefox & ie7 */
* html .thumbimage { /* for ie6 */
width: expression(this.width > 100 && this.width > this.height ? 100 : auto);
height: expression(this.height > 100 ? 100 : auto);
}


方法二

css图片等比例缩放
css图片等比例缩放.

 代码如下 复制代码
thumbimaged{max-width: 650px;max-height: 650px;}/* for firefox & ie7 */* html .thumbimaged{/* for ie6 */width: expression(this.width > 650 && this.width > this.height

方法三

在图片调用中调用该css样式
------------------------------------------


方法实例四

 代码如下 复制代码
#image1{
width: expression(this.width > 980 && this.width > this.height ? 730 : true);
    height: expresion(this.height > 980 ? 730 : true);
}


如果图片宽超过980,去980,不足980,取原宽

 

 

热门栏目