【发布时间】:2014-01-04 17:48:01
【问题描述】:
我刚开始使用 HTML 和 CSS 制作简单的网页,我想将我的内容放在页面中间。使用我的代码,我的内容从左侧和右侧居中,但我也想从顶部和底部居中。如果您要测试我的代码,您会看到顶部没有间距。我将如何解决这个问题,使其不仅从左到右,而且从顶部和底部都有中心?
我的 CSS 代码如下所示:
body {
width: 100%;
height: 100%;
background-color: green;
}
#homePage {
width: 960px;
height: 600px;
background-color: white;
margin: 0 auto;
}
我的 html 代码如下所示:
<body>
<div id="homePage">
<header> Logo and Twitter </header>
<ul id="pageNav">
<li><a href="index.html">Home</a></li>
<li><a href="features.html">Features</a></li>
<li><a href="purchase.html">Purchase</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
<footer> Content for footer goes here </footer>
</div>
</body>
【问题讨论】:
-
查看HERE
-
stackoverflow.com/questions/12415661/…查看上面的链接,您可以在那里找到答案