html - 如何让 nav 和 footer 超过 1000px?

标签 html css

我的 wrapper 是 1000 像素。我怎样才能让我的导航栏和页脚成为整个页面?如果尝试从包装器中取出导航和页脚,则不会居中。

<html>
<head>
<meta charset="utf-8"/>
<title>  
</title>
</head>
<body>
    <div id="wrapper">
    </div>
</body>
</html> 

CSS

*{
margin:0px;
padding:0px;
list-style-type:none;
}
body
{
background:white;
text-align:center;
font-family:Arial;
font-size:12px;
}
#wrapper
{
 width:1000px;
 margin:2px auto 2px auto;
 text-align:left;
 }

最佳答案

将 nav 和 footer 放在 wrapper 之外。和:

#wrapper
{
 width:1000px;
 margin:2px auto 2px auto;
}

footer, #footer, .footer, nav .nav, #nav /* etc - whatever you're using */  {
 width:100%;
 text-align: center;
}

如果您希望所有内容都集中在这些区域中,而不仅仅是文本。将 #wrapper 更改为类而不是 id ( .wrapper ),然后添加到页脚或导航栏中。例如

<footer>
 <div class='wrapper'>
  <!-- content here -->
 </div>
</footer>

希望这能回答您的问题,因为它有点不清楚。

关于html - 如何让 nav 和 footer 超过 1000px?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18795632/

相关文章:

asp.net - 菜单中的固定高度和重复列 - CSS

html - 居中 block 引用但保持文本左对齐

html - 溢出?随着容器尺寸变大,元素被推出

css - 位置 :absolute image inside position:relative not showing in IE

html - StreamReader 返回符号(使用 HttpWebRequest)

php - 隐藏一个 div,它是一个特定 wordpress 页面上所有页面的一部分

html - 我的 float :left in CSS 有问题吗

javascript - 滚动时在元素上覆盖固定标题

javascript - jQuery 加载屏幕到纯 JavaScript

html - 文字掉出盒子