JavaScript控制固定边框,图片全部展示
function fiximg(wimg,maxwidth,maxheight){ var rwidth = wimg.width; console.log(wimg); var rheight = wimg.height; if(rwidth<=maxwidth&&rheight<=maxheight){ wimg.width = rwidth; wimg.height = rheight; }else { if(rwidth/rheight<maxwidth/maxheight){ wimg.height = maxheight; wimg.width = wimg.width*maxheight/wimg.height; }else{ wimg.width = maxwidth; wimg.height = wimg.height*maxwidth/wimg.width; } } } window.onload = function(){ var xx = document.getElementById('cimg'); fiximg(xx,400,400); }
JavaScript控制固定边框,图片全部展示
posted on 2019-05-08 18:48 longlongcheng 阅读(237) 评论(0) 编辑 收藏 举报