简体   繁体   English

如何在CSS中获取页面宽度。

[英]How do I get the page width in a css.

How do I get the page width in a css. 如何在CSS中获取页面宽度。 Getting window width/height is easy. 获取窗口的宽度/高度很容易。 eg: Height: 100% sets the height to 100% of the window height. 例如:高度:100%将高度设置为窗口高度的100%。 I want to set it to 100% of the page size. 我想将其设置为页面大小的100%。 because if we zoom when using window size, max size it takes is of the window. 因为如果我们在使用窗口大小时进行缩放,则它所占用的最大大小就是该窗口。

jquery can give you a solution as follows: jQuery可以为您提供以下解决方案:

$(window).height();   // returns height of browser viewport
$(document).height(); // returns height of HTML document

so you can use $(document).height(); 因此您可以使用$(document).height();

暂无
暂无

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

相关问题 如何仅使用JS或CSS动态更改页面上的colspan。 - How do I change the colspan dynamically on page using only JS or CSS. 如何在 HTML CSS 中使我的滚动始终位于页面的末尾。 我希望我的卷轴总是在页面的末尾 - How do I make my scroll always in the end of the page in HTML CSS. I want my scroll to always be at the end of the page Javascript / jQuery / CSS。 如何在目标div之外维护拖动事件? - Javascript/jQuery/CSS. How do I maintain drag events outside the target div? 我是 CSS 的新手。 如何将 CSS 应用于此 JS Fetch 代码以更改文本 position,字体? - I am new to CSS. How do I apply CSS to this JS Fetch code to alter text position, font? 如何在没有js的css中获得宽度 - how do I get width in css, without js Twitter Widget被CSS扭曲了。 我该如何解决 - Twitter Widget is being distorted by css. How can I fix it NextJS:如何让这个组件在页面加载时显示宽度? - NextJS: How do I get this component to display width on page load? CSS,如何仅在第一页加载时将最小高度/宽度设置为屏幕高度/宽度? - CSS, How do I set the min-height/width to the screen height/width only on first page load? 如何缩短输入字段的宽度 - Bootstrap v5 或 CSS。 保持其响应能力 - How to shorten width of input field - Bootstrap v5 or CSS. keeping its responsiveness 关于jquery 点击添加CSS 等元素删除CSS。 怎么做? - About jquery Click to add CSS and other elements to remove CSS. How to do it?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM