0

我正在使用 Bootstrap 编写 Rails 应用程序。我想为它设置一个图像背景,我已经使用override.css.scss文件完成了。app/assets/images/查看文件夹中我的图像时,背景显示为白色。

如果我将图像设置为外部资源,则显示正常。

用本地图像覆盖的 CSS:

html, body {
    padding-top: 60px;
    background-image: url('app/assets/images/nyc.png');
    /* background-repeat: no-repeat; */
    background-color: transparent;
    height: 1000px;

}

用外部图像覆盖的 CSS:

html, body {
    padding-top: 60px;
    background-image: url('http://www.google.com/intl/en_com/images/srpr/logo3w.png');
    /* background-repeat: no-repeat; */
    background-color: transparent;
    height: 1000px; 
}

莫名其妙。

4

1 回答 1

0

CSS 中的相对 URL 是相对于 CSS 文件的,所以您可能指向了错误的位置?

/path/to/app/assets/images/nyc.png
/path/to/style.css

除非您的 CSS 文件位于此处,相对于相关文件,否则您将在该图像上获得 404。

于 2012-09-20T12:21:00.557 回答