我正在尝试使容器填满整个页面(或视口,以较大者为准),但遇到了一些麻烦.我正在使用这篇文章中的建议:
https://stackoverflow.com/a/17555766,设置< html>和< body>到100%的高度.
但我注意到.Content div仅在< body>时填充视口.高度设置为高度:100%,但不是最小高度:100%.这是为什么?为什么不.Content获取< body>的高度什么时候设置最小高度?有没有解决这个问题(没有绝对定位或固定高度)?
HTML
Content
CSS
* {
margin: 0;
padding: 0;
}
html {
height: 100%;
}
body {
/* does not work for .Content: */
min-height: 100%;
/* does work for .Content: */
/* height: 100%; */
background: blue;
}
.Content {
background: red;
min-height: 100%;
}
P.s.:当< body>高度设置为高度:100%,最小高度:100%和高度:100%按预期工作.Content.