简体   繁体   English

如何限制 Google chrome 扩展弹出窗口的大小?

[英]How to restrict the size of a Google chrome extension popup?

I am creating a Google Chrome extension that does some basic search based on the choices provided.我正在创建一个 Google Chrome 扩展程序,它会根据提供的选择进行一些基本搜索。

This is how it looks so far这是到目前为止的样子

在此处输入图像描述

The problem is that there is a lot of white space on the sides which does not look good, especially because this is a popup and overlays on the current page.问题是侧面有很多看起来不太好的空白区域,特别是因为这是一个弹出窗口并覆盖在当前页面上。

How can I make sure that the popup uses the minimum amount of space required?如何确保弹出窗口使用所需的最少空间?

It should be as simple as styling the body element.它应该像设置body元素的样式一样简单。 Do you want a fixed size, fixed width, or just less margins?你想要一个固定的大小、固定的宽度,还是只需要更少的边距? For fixed size, you should use overflow:scroll or overflow:hidden along with the appropriate width and height .对于固定大小,您应该使用overflow:scrolloverflow:hidden以及适当的widthheight For fixed width, use width and optionally min-height .对于固定宽度,使用width和可选min-height For any of these, you should check the margins on all the block-level elements to see if that's where your whitespace is coming from.对于其中任何一个,您应该检查所有块级元素的边距,看看您的空白是否来自哪里。

as nkorth said, this is quite easy, using CSS.正如 nkorth 所说,这很容易,使用 CSS。 Let me write out the code for you:让我为你写出代码:

<html>
  <head>
     <style type="text/css">
         body {
            width: 200px;
            height: 200px;
            overflow: hidden;
         }
     </style>
  </head>
  <body>
     text text text
  </body>
</html>

You can follow Debugging Tutorial to inspect this popup.您可以按照调试教程检查此弹出窗口。

Maybe set the min-width property to body element could fix it.也许将min-width属性设置为body元素可以修复它。 If not, please append the html code, we can check it later.如果没有,请 append html 代码,我们可以稍后查看。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM