【发布时间】:2014-03-16 00:29:03
【问题描述】:
我有一个 div 用作“侧面板”,其宽度:100% 和位置:固定。这个侧面板包含我的导航。我还有另一个名为“内容”的 div。它的宽度为 600 像素,我习惯使用“margin-left:auto,margin-right:auto”将其居中在侧面板和页面边缘之间。
但问题是两个 div 重叠。如何阻止它重叠? 我在下面包含了 HTML 和 CSS 编码。
HTML
<body>
<div id="leftpanel">
<div id="nav">
<ul>
<li><a href="index.html">home</a></li>
<li><a href="">the future</a></li>
<li><a href="">contact details</a></li>
</ul>
</div>
</div>
<div id="content">
<div id="header">
<p><img src="images/haroon-ahmed.png" class="imgaligncentre"/></p>
</div>
</div>
</body>`
CSS
#leftpanel {
float:left;
height:100%;
width:320px;
postion:fixed;
}
#content {
width:600px;
padding-top:50px;
padding-bottom:50px;
margin-right:auto;
margin-left:auto;
}
【问题讨论】: