将页面分成上下两半(顶部和底部)。

9
我想将一个页面分成两半(不是列,而是行,即上下两部分),并且为上下两半分别赋予不同的颜色。
2个回答

15

demo on dabblet.com

html:

<div id="top">top</div>
<div id="bottom">bottom</div>

CSS:

#top,
#bottom {
    position: fixed;
    left: 0;
    right: 0;
    height: 50%;
}

#top {
    top: 0;
    background-color: orange;
}

#bottom {
    bottom: 0;
    background-color: green;
}

4

示例:Jsfiddle

HTML

<body>
<div style="height:100%">
<div class="topdiv">top div</div>
<div class="bottomdiv">bottom div</div>
</div>

CSS

body {margin:0;padding:0;height:100%;}
div.topdiv {clear:both;position:fixed;top:0;height:50%;width:100%;background-color:#990000;color:#FFFFFF;font-size:16px;text-align:center;}
div.bottomdiv {clear:both;position:fixed;bottom:0;height:50%;width:100%;background-color:#009900;color:#FFFFFF;font-size:16px;text-align:center;}​

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接