gpt4 book ai didi

css - 为什么我看不到使用 bootstrap CSS 设置的背景图片,但可以看到外部图片资源?

转载 作者:行者123 更新时间:2023-11-28 13:40:02 28 4
gpt4 key购买 nike

我正在使用 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;
}

莫名其妙。

最佳答案

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

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

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

关于css - 为什么我看不到使用 bootstrap CSS 设置的背景图片,但可以看到外部图片资源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12512290/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com