javascript 如何阻止浏览器窗口在特定大小后调整大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18717698/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to stop the browser window from resizing after a specific size
提问by Paul Shan
How to give a minimum width to the browser window, so that the user can't make it smaller after a specific size. But he can make it larger than that. Something like applying the 'min-width' property of css to the browser window itself. Is it possible any way?
如何为浏览器窗口提供最小宽度,以便用户无法在特定大小后使其变小。但他可以让它变得更大。类似于将 css 的“min-width”属性应用于浏览器窗口本身。有可能吗?
回答by Halcyon
You can notcontrol the size of the window. You can use CSS to set min-width
and min-height
properties to ensure your page layout stays sane.
您无法控制窗口的大小。您可以使用 CSS 来设置min-width
和min-height
属性以确保您的页面布局保持合理。
回答by LDJ
You wont be able to affect the client size browser window with CSS. The CSS min/max widths will stop the content from 'shrinking' beyond a certain point, but you cannot (rightly so) prevent the user from controlling the size of their own browser.
您将无法使用 CSS 影响客户端大小的浏览器窗口。CSS 最小/最大宽度将阻止内容“缩小”超过某个点,但您不能(正确地)阻止用户控制他们自己的浏览器的大小。
You may be able to do it using JavaScript, but then you need to ask the question WHY are you doing this - if its for a design then I'd seriously question the quality of the design.
您也许可以使用 JavaScript 来做到这一点,但是您需要问为什么要这样做 - 如果是为了设计,那么我会严重质疑设计的质量。