简体   繁体   English

div高度100%

[英]Height of div 100%

I want to make a div 100% height, so basically the full screen. 我想将div的高度设为100%,因此基本上是全屏。 This, so that the background streches over the whole page. 这样,以便背景在整个页面上伸展。 I don't want to add the background to the body, since i want it so that if i comment out the wrapper, the page is full width. 我不想将背景添加到正文中,因为我想要它,以便如果我注释掉包装纸,则页面为全宽。 (which works by the way) (顺便说一句)

So basically my question is: how can i make the wrapper-bg div 100% high. 所以基本上我的问题是:如何使wrapper-bg div高100%。

Hope you guys can help me. 希望你们能帮助我。

Try with .wrapper-bg {position:fixed; 尝试使用.wrapper-bg {position:fixed; top: 0px; 顶部:0px; bottom:0px} 底部:0px}

html,body{height: 100%} html,body {高度:100%}

Make sure that your parent element has height 100% and it should be positioned as relative. 确保您的父元素的高度为100%,并且应相对放置。 Try making it absolute. 尝试使其绝对。 Your child div strech to parent height. 您的孩子将步幅拉伸至父母身高。

将主体高度设置为100%,因为div宽度或高度仅在将父代设置为某个值时才适用,例如,如果主体100%div高度为100%将起作用,则确定父代

Try this, should work as you have to make all parent elements 100%. 尝试此操作,因为您必须将所有父元素都设为100%,所以应该可以工作。

html, body {height: 100%}

.yourdiv {height: 100%}

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

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