简体   繁体   English

将页面的一部分拉伸到最大高度

[英]Stretch a section of page to full height

I was wondering how can I stretch a section of the page to full height and width? 我想知道如何将页面的一部分拉伸到整个高度和宽度? Like a full-screen section 100% percent of the window. 就像全屏部分一样,是窗口的100%。 Well not if you resize it but of your maximum height. 好吧,如果您调整大小,则不要超过最大高度。 I can't find out how to do that. 我不知道该怎么做。 How do I do? 我该怎么办?

You should set height to your body to be 100% and then set the height of the section you want to be 100% height, this should result in that particular section to take the full height of browser. 您应该将身体的高度设置为100%,然后将要设置的部分的高度设置为100%的高度,这将导致该特定部分占据浏览器的整个高度。 Also add width 100% to both body and section if you want full width as well. 如果还需要全宽,还可以在主体和截面上都添加100%的宽度。

Use this CSS for the section: 请将此CSS用于以下部分:

#your_section {
  width: 100vw;
  height: 100vh;
}

The vh and vw units are actually percentages of the viewport width and height, but other than regular percentage values, they are not relative to the parent element, but only to the viewport itself. vhvw单位实际上是视口宽度和高度的百分比,但除常规百分比值外,它们与父元素无关,而仅与视口本身有关。

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

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