首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在整页上显示容器

在整页上显示容器
EN

Stack Overflow用户
提问于 2014-05-22 07:33:20
回答 2查看 59关注 0票数 1

编辑:小提琴

我已经准备好

代码语言:javascript
运行
复制
html{
height: 100%;
}

代码语言:javascript
运行
复制
body{
min-height: 108%;
}

我想将content显示为footer的完全高度,即使content是空的。

我是container

这是content

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-05-22 07:50:23

除了在height:100%元素中添加min-height:108%之外,还可以通过添加min-height:108%来修复这个问题:

http://jsfiddle.net/C8UUt/1/

代码语言:javascript
运行
复制
body {
    font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;

    background: #42413C;
    margin: 0;
    padding: 0;
    color: #000;
    min-height: 108%;
    height: 100%;
}

更新

要使sidebar1达到完全高度,可以使用一个小技巧:

http://jsfiddle.net/C8UUt/3/

代码语言:javascript
运行
复制
.container {
    width: 960px;
    background: #FFF;
    margin: 0 auto;
    min-height: 100%;
    position: relative; // added this to tell position:absolute that this is his parent
}

.sidebar1 {
    float: left;
    width: 180px;
    background: #EADCAE;
    padding-bottom: 10px;
    display: inline-block;
    height: 100%; // to make it 100% height
    position: absolute; // added this so it will take `min-height` of parent into account
}
.content {
    padding: 10px 0;
    width: 780px;
    display: inline-block;
    /* float: left; */
    height: inherit;
    margin-left: 180px; // since position:absolute doesn't take part in the normal flow, we must account for that space manually
}
票数 2
EN

Stack Overflow用户

发布于 2014-05-22 07:48:44

如果您的浏览器支持CSS3,请使用以下内容:

代码语言:javascript
运行
复制
.container {height:100vh;}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23800481

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档