css expression实现的图片自动缩放
摘要:下面给出一个示例:.Image{max-width:600px;height:auto;cursor:pointer;border:1pxd...
下面给出一个示例:
<style>
.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));
}
</style>
这里使用了expression,但是利用了一次加载,所以expression不会造成内存泄漏。
我们可以这样去用它:
<IMG SRC="test.jpg" WIDTH="990" HEIGHT="2000" BORDER="0" ALT="">
这样,当一张图片超过指定宽度时,则会进行自动缩放显示。
【css expression实现的图片自动缩放】相关文章:
上一篇:
常用的CSS命名规则 web标准化设计