1

在我的页面顶部,我有一个标题(div),距离页面顶部只有几 px 的距离。在 div 中,我得到了页面标题,并将其放置在左上角(这是正常的)。但它位于 div 的底部(仍在右侧)。这是我的html:

<body>
    <div id="header">
        <h1>x</h1>
    </div>
</body>

还有我的 CSS:

#header {
    width: 700px;
    height: 200px;
    margin-left: auto;
    margin-right: auto;
    background-color: #ffffff;
    color: #cdffaf;
    font-size: 30px;
}

h1 {
margin-top: 5px;    
}
4

1 回答 1

1

你可以display: table-cell使用vertical-align: bottom;

演示

颜色已更改(可见性)

于 2013-04-18T19:11:48.053 回答