<script type="text/javascript"> function Zoom(obj, width, height){ var img = new Image(); img.src = obj.src; var scale = Math.max(width / img.width, height / img.height); var newWidth = img.width * scale; var newHeight = img.height * scale; var div = obj.parentNode; obj.width = newWidth; obj.height = newHeight; div.style.width = width + "px"; div.style.height = height + "px"; div.style.overflow = "hidden"; obj.style.marginLeft = (width - newWidth) / 2 + "px"; obj.style.marginTop = (height - newHeight) / 2 + "px"; } </script> <div><img src="https://hiphotos.baidu.com/中国旅游名县/pic/item/56d16e00e83803a6e850cdb2.jpg" width="400" height="300" border="0" /></div>
JS缩略图自动缩放显示
未经允许不得转载:NixonLi博客 » JS缩略图自动缩放显示
相关推荐
-      timthumb不能使用外链图片的解决方法
-      为WordPress添加轻量级"回到顶部"代码
-      WordPress百度收录代码
-      WordPress 主题添加影视分类
-      wordpress入门教程-WordPress 安装主题
-      wordpress入门教程-如何安装WordPress
-      WordPress 文章浏览量统计,刷新不重复统计
-      WordPress 全站https访问SSL插件”Really Simple SSL”