Chrome扩展程序页面popup.html不会调整大小 [英] Chrome Extension page popup.html doesn't resize

查看:1267
本文介绍了Chrome扩展程序页面popup.html不会调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我有这个Chrome扩展程序可以从互联网上加载一些内容。基本上用户点击弹出图标,然后后台页面中的一些JavaScript加载一些页面,从中解析图像并将其放入popup.html页面。问题是popup.html没有调整大小以适应内容的实际大小。我在StackOverflow上看到了一些类似的问题,每个人都回答在你的popup.html页面的顶部放置<!DOCTYPE html> ,在我的情况下不工作。弹出窗口的尺寸非常小(约1平方厘米)。

以前我有一些CSS样式可以固定宽度&高度,但我注意到我的内容并不总是相同的大小,所以我希望popup.html页面自动调整大小以适应内容。



我知道在最糟糕的情况是我可以解析图片的宽度和高度,并将其设置为CSS,但我觉得有一个更优雅的解决方案。



谢谢

解决方案

我能够使用一点jQuery动态调整弹出窗口大小。



$('html')。height($('#menu')。height()); $ b

其中#menu只是一个包装所有内容的div。 body 没有正确调整大小,所以我无法使用它。

显然,改变 html 的高度就足够了。


So I have this Chrome Extension that loads some content off the internet. Basically the user clicks on the popup icon, then some JavaScript in the background page loads some page, parse an image from it and puts it into the popup.html page. The problem is that the popup.html is not resizing to fit the actual size of the content. I saw a couple of similar questions here on StackOverflow, each one answered with "put <!DOCTYPE html> on top of your popup.html page" which in my case is not working. The size of the popup remains very small (about 1cm square).

Previously I had some CSS style that fixed the width & height but I noticed my content is not always the same size, so I would like the popup.html page to automatically resize itself to fit the content.

I know that in the very worst case I could parse width and height of the image and set it as CSS but I feel like there is a more elegant solution.

Thanks

解决方案

I was able to dynamically resize the popup with a little bit of jQuery.

$('html').height($('#menu').height());

Where #menu is just a div that wraps all of the content. body didn't properly resize, so I couldn't use that.

Apparently just changing the height of html is enough.

这篇关于Chrome扩展程序页面popup.html不会调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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