CSS将图片放在页面顶部

nos*_*e25 4 css background-image background-position

我需要在CSS的网页顶部中心放置一个图像。现在,我只是使用background-image:in css,但这将其放在页面的中间。

这是我的代码:

body {
  background-image: url("theimageurlgoeshere"); //The image is 842 x 508
  background-attachment:fixed;
  background-position: center top;
  background-repeat: no-repeat;
}
Run Code Online (Sandbox Code Playgroud)

此外,更改外观background-position:似乎对网站的结果没有影响。任何帮助表示赞赏。

Ril*_*ley 5

将这些值的排列从更改center toptop center

background-position: top center;
Run Code Online (Sandbox Code Playgroud)

在Safari 4,Chrome和FF 3.5中测试

我在测试中使用的代码是:

 body { background: url(./image.png) no-repeat top center; }
Run Code Online (Sandbox Code Playgroud)