背景并没有显示出来

时间:2014-04-03 15:23:55

标签: html css background

当我使用'不重复'时,背景正在运行,但一旦我改为'不重复',就没有背景。我试图在CSS中定义背景。

body
{ font: normal 80% Arial, Helvetica, sans-serif;
  color: #000;
  background: #4E5869;
  background-image:  url(../images/bg_body.jpg) no-repeat;
 }

非常感谢您的帮助。

干杯

4 个答案:

答案 0 :(得分:2)

no-repeatbackground-repeat值,而不是background-image值......

background-image: url(...);
background-repeat: no-repeat;

OR:

background: #4E5869 url(...) no-repeat;

答案 1 :(得分:0)

为什么不试试这个:

body
{ font: normal 80% Arial, Helvetica, sans-serif;
  color: #000;
  background-color: #4E5869;
  background-image:  url(../images/bg_body.jpg);
  background-repeat: no-repeat;
 }

现在background-colorbackground-image分开提供。

当您在其中拨打background时,可以先拨打color,然后拨打image-url image-positionbackground-repeat。但是,当您致电background-image时,您只需拨打image-url

 body
    { font: normal 80% Arial, Helvetica, sans-serif;
      color: #000;
      background-color: #4E5869;
      background-image:  url(../images/bg_body.jpg);
      background-repeat: no-repeat;
     }

OR

body
    { font: normal 80% Arial, Helvetica, sans-serif;
      color: #000;
      background: #4E5869 url(../images/bg_body.jpg) no-repeat;
     }

答案 2 :(得分:0)

这将有效:

body {
  font: normal 80% Arial, Helvetica, sans-serif;
  color: #000;
  background: #4E5869 url(../images/bg_body.jpg) no-repeat;
}

background-image是图片,而不是您希望提供的任何规则。你可以按照你的风格去做:

body {
  font: normal 80% Arial, Helvetica, sans-serif;
  color: #000;
  background: #4E5869;
  background-image:  url(../images/bg_body.jpg);
  background-repeat: no-repeat;
}

非常平等。 一些要阅读的内容:http://www.w3schools.com/cssref/pr_background-repeat.asp

答案 3 :(得分:0)

您不能将不重复作为背景图片的一部分(所有接受的,是图片的网址)

您需要使用 background-repeat

https://developer.mozilla.org/en-US/docs/Web/CSS/background-repeat

相关问题