0

我正在尝试在此示例中实现相同的目标……我希望我的导航与该网站上的一样。

HTML

<div id="container">
    <div id="nav"></div>
</div>

CSS

#container {
    width: 980px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
}

#nav {
    width: 100%
    background: #585858;
    height: 37px;
}

repeat-x;我正在尝试获得与导航相同的效果

4

3 回答 3

1
#container
{
  width:980px;
}
#nav{
  position:absolute;
  left:0;
  right:0;
  /*...no need of width:100%;..*/
}

例子

于 2013-09-13T05:38:31.877 回答
1

也许你想实现这样的目标:http: //jsbin.com/oWeKiqa/2/

在你的 CSS 上试试这个:

#container {
    width: 980px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
}

#nav {
    width: 100%;
    background: #585858;
    height: 37px;
    left: 0;
    display: block;
    position: absolute;
}
于 2013-09-13T05:56:43.433 回答
0

添加overflow:hidden;到容器 div 并且不要忘记您有错字,因为您忘记在属性;末尾添加,width因此它不会被应用。

http://jsbin.com/efilOSA/1/

于 2013-09-13T05:46:04.947 回答