简体   繁体   English

div不占整个高度/不是100%

[英]div doesn't take the whole height / is not 100%

here is the live link: http://mrgsp.md:8080/a/Account/SignIn 这是实时链接: http//mrgsp.md8080 / a / Account / SignIn

the main div (green one) doesn't take 100% of the screen height 主div(绿色)不占用屏幕高度的100%

you will notice this only if you have a big screen 只有当你有一个大屏幕时才会注意到这一点 替代文字

and the code is basically 而代码基本上是

<body>
<div class="loginpage">
<div id="loginbox">stuff inside loginbox</div>
</div>
</body>

.loginpage {
background:none repeat scroll 0 0 green;
padding:200px;
}

Sorry for my english... 对不起我的英语不好...

put the background style in body... is better. 把背景风格放在身上...更好。

body{
  background: green;
}

if you still want to put a height for the div, you must to put 100% height for div, for body and for html too. 如果你仍想为div设置一个高度,你必须为div,body和html设置100%的高度。

html, body, .loginpage{
  height: 100% ;
}

你可以给身体绿色背景颜色?

You can't simply set a div height to 100%, because it will interpret that as 100% of its container . 您不能简单地将div高度设置为100%,因为它会将其解释为其容器的100%

The simplest solution to your problem is to set the background color on the body element, but alternatively, you can use your method by setting the body tag to have a height of 100%. 解决问题的最简单方法是在body元素上设置背景颜色,但也可以通过将body标记设置为100%的高度来使用您的方法。 This will give your div something to fill fully. 这将给你的div充分填充。 If the body or whatever container of the div doesn't have a height set, then the browser defaults the css property of the div to height: auto. 如果div的主体或任何容器没有设置高度,则浏览器将div的css属性默认为height:auto。

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

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