资源预览内容
第1页 / 共2页
第2页 / 共2页
亲,该文档总共2页全部预览完了,如果喜欢就下载吧!
资源描述
利用JS自动缩小超出大小的图片尺寸我们在做网站中,往往会出现一些超大的图片,把页面撑开变形,影响了美观。用这段JS代码就可解决这个问题,你可以把图片的最大值限定在一定范围内,当图片大小超出这个尺寸后,就会被自动缩小。 0 & image.height0) flag=true; if(image.width/image.height= 200/200) if(image.width200) ImgD.width=200; ImgD.height=(image.height*200)/image.width; else ImgD.width=image.width; ImgD.height=image.height; else if(image.height200) ImgD.height=200; ImgD.width=(image.width*200)/image.height; else ImgD.width=image.width; ImgD.height=image.height; /- 把上边的这段代码加入之中 在相关图片上加入以下代码或者把onload的代码加入到body里:
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号