Css 标题中未显示背景图像

Css 标题中未显示背景图像,css,background-image,Css,Background Image,我想将背景图像添加到标记,但图像不显示 header { background-image: url("/img/header-bg.jpg"); background-repeat: repeat-x; width: 100%; height: 105px; background: #fff; position: relative; display:block } 当我在Chrome中使用开发者工具时,我可以看到图像的URL是好的(我可

我想将背景图像添加到
标记,但图像不显示

header {
    background-image: url("/img/header-bg.jpg");
    background-repeat: repeat-x;
    width: 100%;
    height: 105px;
    background: #fff;
    position: relative;
    display:block
}
当我在Chrome中使用开发者工具时,我可以看到图像的URL是好的(我可以看到图像),但让我困惑的是,当我添加

background-image: url("/img/header-bg.jpg");
background-repeat: repeat-x;

作为Chrome中
标题的新样式规则,背景图像将显示。

使用相同的背景属性将仅反映颜色。因此,请参考以下代码:

header {
  background:#fff url("/img/header-bg.jpg") repeat-x;
  background-repeat: repeat-x;
  width: 100%;
  height: 105px;
  position: relative;
}

使用相同的背景属性将仅反映颜色。因此,请参阅以下代码:

header {
  background:#fff url("/img/header-bg.jpg") repeat-x;
  background-repeat: repeat-x;
  width: 100%;
  height: 105px;
  position: relative;
}

background
属性更改为
background color
,或者在不需要时将其删除

background
是一个简写css属性,它将覆盖所有其他以前的样式

您的代码应该是:

header {
  background-image: url("/img/header-bg.jpg");
  background-repeat: repeat-x;
  background-color: #fff;
  width: 100%;
  height: 105px;
  position: relative;
  display:block
}

或简写如下:

header {
  background: #fff url("/img/header-bg.jpg") repeat-x;
  width: 100%;
  height: 105px;
  position: relative;
  display:block

}

background
属性更改为
background color
,或者在不需要时将其删除

background
是一个简写css属性,它将覆盖所有其他以前的样式

您的代码应该是:

header {
  background-image: url("/img/header-bg.jpg");
  background-repeat: repeat-x;
  background-color: #fff;
  width: 100%;
  height: 105px;
  position: relative;
  display:block
}

或简写如下:

header {
  background: #fff url("/img/header-bg.jpg") repeat-x;
  width: 100%;
  height: 105px;
  position: relative;
  display:block

}

background
属性更改为
background color
或将其删除
background
是一个简写css属性,它将覆盖以前的所有其他样式。请交换
背景图像
背景
的顺序,或者不使用
背景
,使用
background color
@MuhammadUsman既然你已经解释了我做错了什么,你能把它写下来作为回答吗将
background
属性更改为
background color
或删除它
background
是一个简写css属性,它将覆盖以前的所有其他样式。请交换
背景图像
背景
的顺序,或者不使用
背景
,使用背景色既然你解释了我做错了什么,你能写下来作为回答吗?或者你可以使用背景色欢迎,如果你觉得上面给出的答案是正确的,打勾。既然穆罕默德·乌斯曼解释了我做错了什么,我给了他正确的答案,我想他以前也发过。但是你的答案也是正确的。或者你可以使用背景色Welcome,如果你觉得上面给出的答案是正确的,打个勾。因为穆罕默德·乌斯曼解释了我做错了什么,我给了他正确的答案,我想他以前也发过。但是你的也是正确的。