【发布时间】:2014-03-31 14:51:43
【问题描述】:
所以我有一个带有以下 css 的背景图片:
body{
background-image:url(cover.jpg);
background-repeat:no-repeat;
background-position:center;
background-attachment:fixed;
}
背景图片宽度为 1280 像素。所以我希望我的导航栏固定并以背景为中心。但是我遇到了问题。这是我的代码。
#navigation {
margin: 0 auto;
position:fixed;
top: 0;
width: 1280px;
height: 35px;
padding-top: 10px;
background-color: #000000;
}
但导航栏会固定但不会居中。如果我删除固定的,它将居中但它不固定。
有什么方法可以做到这一点?
【问题讨论】:
-
添加 html 的 sn-p 会有所帮助
-
如何添加 html 帮助?
<html> <head> <link rel="stylesheet" type="text/css" href="page.css"> </head> <body> <div id="navigation"> </div> </body> </html>