开发者

Creating vertical space in CSS

So, I've got a box in the center of t开发者_JAVA百科he page (vertically and horizontally) with a fixed height (200px)

It contains two elements, of arbitrary height. I want one to be anchored to the top, and one to be anchored to the bottom of the box.

CSS3 is fine for this, so please use it if the stylesheet is clearer.


The html:

   <div id="outer">
        <div class="top">
        </div>

        <div class="bottom">
        </div>
    </div>

The styling:

#outer {
    width:100px; /* whatever */
    height: 200px;
    position:relative;
}

.top {
    position:absolute;
    top:0px;
}

.bottom {
    position:absolute;
    bottom:0px;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜