首页 > 编程语言 > 详细

JavaScript控制固定边框,图片全部展示

时间:2019-05-08 20:18:34      阅读:112      评论:0      收藏:0      [点我收藏+]
        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控制固定边框,图片全部展示

JavaScript控制固定边框,图片全部展示

原文:https://www.cnblogs.com/lola/p/10833708.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!