Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 向导航框添加背景图片_Css_Navigation - Fatal编程技术网

Css 向导航框添加背景图片

Css 向导航框添加背景图片,css,navigation,Css,Navigation,我的导航栏有以下CSS: nav { position: fixed; top: 0; left: 0; width: 100%; height: 90px; line-height: 40px; text-align: center; border: 1px solid #ccc; border-width: 1px 0; background-color: #000000; } nav li { display: inline; } na

我的导航栏有以下CSS:

nav { 
  position: fixed;
  top: 0; 
  left: 0;
  width: 100%; 
  height: 90px;
  line-height: 40px;
  text-align: center; 
  border: 1px solid #ccc;
  border-width: 1px 0;
  background-color: #000000; 
}

nav li { display: inline; }

nav a {
    display: inline-block;
    padding: 10px;
}
但是,我想要一张图片,而不是黑色的背景色。请注意,导航栏是固定的,因此导航菜单后面的图片也应该固定


这可能吗?

试试下面的方法怎么样

nav {
    background-image: url('/url/to/image.jpg');
    background-repeat: no-repeat;
    background-attachment: fixed;
}
nav { background: #000 url('imageURL.jpg') no-repeat fixed; }