1

我在为我正在处理的网站创建全屏弹出窗口时遇到了一些问题。布局需要如下:

在此处输入图像描述

head 和 footer 都需要固定高度,body 高度会根据浏览器窗口的高度进行伸缩。

我怎样才能做到这一点?

编辑:我忘了提到中间部分需要溢出:滚动大于页面高度的内容。

4

3 回答 3

4

你可以用box-sizing属性来做到这一点。

像这样:

小提琴 1 小提琴2

.container
{
    height: 100%;
    background: pink;
    margin: -64px 0;
    padding: 64px 0;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
.content {
    overflow:auto;
    height:100%;
}
header
{
    height: 64px;
    background: purple;
    position: relative;
    z-index:1;
}
footer
{
    height: 64px;
    background: gray;
    position: relative;
    z-index:1;
}
于 2013-06-25T07:15:44.130 回答
2

试试这个简单的选项http://jsfiddle.net/jaisonje/mRBJj/并在此处查看滚动条示例

HTML:

<div class="header">Header</div>
<div class="content">Content</div>
<div class="footer">Footer</div>

CSS:

 body, html { height:100%; }
.footer,.header{ position:absolute; top:0; height:50px; background-color:yellow; width:100%;}
.content{ position:absolute; top:50px; bottom:50px; background-color:red;width:100%;}
.footer{ bottom:0; top:auto;}
于 2013-06-25T07:20:47.247 回答
0

在本站下载 Bootstrap.css

http://twitter.github.io/bootstrap/index.html

CSS:

.modal {
        background-clip: padding-box;
        background-color: #FFFFFF;
        border: 1px solid rgba(0, 0, 0, 0.3);
        border-radius: 6px 6px 6px 6px;
        box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
        left: 21.5%;
        margin-left: -280px;
        outline: medium none;
        position: fixed;
        top: 2%;
        width: 98%;
        z-index: 1050;
    }
    .modal-footer {
        background-color: #F5F5F5;
        border-radius: 0 0 6px 6px;
        border-top: 1px solid #DDDDDD;
        box-shadow: 0 1px 0 #FFFFFF inset;
        margin-bottom: 0;
        padding: 14px 15px 15px;
        text-align: left;
    }

HTML:

<div id="myModal" class="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
<p>Modal body…&lt;/p>
</div>
<div class="modal-footer">
Modal Footer

</div>
</div>

脚本: 在引导站点 http://twitter.github.io/bootstrap/index.html上下载 Javascript

<script type="text/javascript" src="bootstrap.min.js"></script>
<script type="text/javascript" src="jquery-1.7.js"></script>

在您的页面上添加此脚本

<script type="text/javascript">
$('#myModal').modal('show')
</script>
于 2013-06-25T07:04:51.057 回答