2012-05-11 150 views
4

我正在设计一个新网站,并且遇到了问题。我想让我的导航栏工作的方式是将它融合到标题(徽标栏)中。如何重叠两个div

下面是它目前看起来编码时一样:

enter image description here

这是我希望它看起来像:

enter image description here

目前,这是我的CSS:

#header { 
margin: 0px auto; 
width: 900px; 
height: 170px; 
background: #000; 
} 

#navigation { 
margin: 0px auto; 
width: 920px; 
height: 60px; 
background: url('images/nav.png'); 
} 

而我的HTML:

 <div id="header"> 

     </div> 


     <div id="navigation"> 

     </div> 

回答

6

,你可以这样写:

#header { 
margin: 0 auto; 
margin-bottom:-30px; 
width: 900px; 
height: 170px; 
background: #000; 
} 
+0

非常感谢您! –

2

marginposition: absolute将解决您的问题。

2

可能会有物品的默认填充和边距,这可能意味着您必须覆盖它,就像第一个带有负边界的答案一样,请指定margin:0;填充:0;或者使用一个CSS复位,以避免这种弄虚作假......

2

添加以下内容: -

margin-top ; -30px;