[英] how do I set height of container DIV to 100% of window height?

查看:69
本文介绍了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的容器DIV有几个问题。对于一个,它不是正确地识别我的内容的高度(我会认为它会超出主要内容和侧边栏的底部,但它不是)。您可以在此页面上查看我的意思。



我也希望容器DIV总是填充屏幕/窗口的可用高度。我尝试将它设置为 min-height:100%,但是没有任何效果。



这里是我用于容器DIV的CSS:

  #container {
padding:0;
margin:0;
background-color:#292929;
width:1200px;
margin:0 auto;
min-height:100%;
}



我将非常感谢任何帮助让这项工作。



感谢,



Nick

解决方案>

将它添加到您的css:

  html,body {
height:100%
}

如果你说height:100%,你的意思是'100%元件'。如果父元素没有指定的高度,则不会发生。你只设置100%的身体,但你还需要将它添加到html。


I have a couple of problems with my container DIV. For one it is not recognising the height of my content correctly (I would have thought it would extend beyond the bottom of the main content and sidebar, but it isn't). You can see what I mean on this page.

I would also like the container DIV to always fill the available height of the screen/window. I have tried setting it to min-height:100%, but this didn't have any effect.

Here is the CSS I am using for the container DIV:

#container {
  padding: 0;
  margin: 0;
  background-color: #292929;
  width: 1200px;
  margin: 0 auto;
  min-height: 100%;
}

I would be grateful for any help to get this working.

Thanks,

Nick

解决方案

Add this to your css:

html, body {
    height:100%;
}

If you say height:100%, you mean '100% of the parent element'. If the parent element has no specified height, nothing will happen. You only set 100% on body, but you also need to add it to html.

这篇关于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆