jQuery调整窗口大小以适合内容 [英] jquery resize window to fit contents

查看:87
本文介绍了jQuery调整窗口大小以适合内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的弹出窗口,显示300x300px图片,我将窗口的大小设置为350x350px,但是根据浏览器的不同,我会得到滚动条或额外的空白.是否有一些jQuery函数可以调整浏览器窗口的大小以适合内容,而无需任何滚动条或空白,无论使用哪种浏览器?

I have a simple popup window that shows 300x300px picture, I set up the size of the window to be 350x350px, but depending on the browser I either get scroll bars or extra white space. Is there some jQuery function that would resize the browser window just to fit the content without any scroll bars or white space, no matter what browser?

帮帮我!

推荐答案

您可以执行以下操作..

You could do something like this..

function windowResize() {
   var contentWidth = document.getElementById("YourImageOrContent").offsetWidth;
   var contentHeight = document.getElementById("YourImageOrContent").offsetHeight;
   window.resizeTo(contentWidth,contentHeight);
}

您可能需要在值上加上20个像素左右...但是我仍然保持原始答案:-D

You may have to add 20 pixels or so to the values... But I still maintain my original answer :-D

这篇关于jQuery调整窗口大小以适合内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆