【发布时间】:2018-06-23 03:43:36
【问题描述】:
这个问题已经被问过很多次了,但我无法解决。
我试图在 Cloud 9 IDE 上的 ruby on rails 应用页面上显示图像,但图像不会出现。
CSS
.hero-image {
/* The image used */
background-image: url("images/banner.jpg");
/* Set a specific height */
height: 50%;
/* Position and center the image to scale nicely on all screens */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
.erb 页面
<div class="hero-image">
</div>
图像存储在 app/assets/images 中
样式表目录:app/assets/stylesheets
我知道文件路径必须是相对于样式表页面的,我做对了不是吗?我也试过把图片移到样式表目录,改成url("banner.jpg"),还是不行。
编辑:
将网址更改为上传到谷歌存储桶的图片链接也不起作用。
background-image: url("https://storage.googleapis.com/#####");
【问题讨论】:
-
你试过
background-image: url(asset_path("images/banner.jpg"));
标签: html css ruby-on-rails ruby cloud9-ide