2014-04-03 62 views
0

当我使用'不重复'背景工作时,但只要我改变为'不重复',就没有背景。我试图在CSS中定义背景。背景不显示

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

希望你的帮助。

干杯

回答

2

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

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

OR:

background: #4E5869 url(...) no-repeat; 
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-urlimage-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; 
    } 
+0

因为这会不会工作? –

+0

见我解释明白我试图指出 – OmniPotens

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

0

不能使用不重复背景图像的部分(全部接受,就是URL的图像)

您需要使用背景重复

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

+0

http://w3fools.com/ –

+0

也许你不喜欢这样的网站 - 但它仍然证明了上述观点,并给出了如何利用这项功能,他举例需要正确的;) –

+0

在这种情况下,也许,但你会做更好的链接到MDN。 –