下面得出1个示例:
<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,可是运用了1次载入,因此expression不容易导致运行内存泄露。
大家能够这样去用它:
<IMG SRC="test.jpg" WIDTH="990" HEIGHT="2000" BORDER="0" ALT="" class="Image">
这样,当1张照片超出特定宽度时,则会开展全自动放缩显示信息。