本文使用「署名 4.0 国际 (CC BY 4.0)」许可协议,欢迎转载、或重新修改使用,但需要注明来源。 [署名 4.0 国际 (CC BY 4.0)](https://creativecommons.org/licenses/by/4.0/deed.zh) 本文作者: 苏洋 创建时间: 2011年01月31日 统计字数: 334字 阅读时间: 1分钟阅读 本文链接: https://soulteary.com/2011/01/31/css%E8%87%AA%E5%8A%A8%E7%BC%A9%E7%95%A5%E5%9B%BE%E7%89%87%E9%80%82%E5%BA%94%E9%A1%B5%E9%9D%A2.html ----- # [CSS]自动缩略图片适应页面 重写的时候,翻CSS看到一段内容,感觉很古老了,但是或许什么时候写简单页面会用上,留下来吧。 ```css .post_img { 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)); } ``` 具体数值,可以修改。比如最大宽度600,适应宽度560等。