按比例缩小图片的CSS代码

代码简介:

CSS按比例缩小图片,有时候图片太大,会破环网页整齐的布局。这时可以用css来强制按比例压缩图片的高度或宽度。提示:这样用CSS来套JS,会损失很大的加载运行速度等。

代码内容:

View Code
<title>按比例缩小图片的CSS代码 - www.webdm.cn</title>
<style>
img,a img
{ 
border
:0;  
margin
:0;  
padding
:0; 
max-width
:200px; 
width
:expression(this.width>200?"200px":this.width); 
max-height
:200px; 
height
:expression(this.height>200?"200px":this.height); 
</style>
<img src="http://www.webdm.cn/images/wall3.jpg">
<br />
<p><href="http://www.webdm.cn">网页代码站</a> - 最专业的网页代码下载网站 - 致力为中国站长提供有质量的网页代码!</p>
代码来自:http://www.webdm.cn/webcode/510d8159-0b80-453a-a7c9-a2b9c79307df.html
原文地址:https://www.cnblogs.com/webdm/p/2160409.html