作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这个问题已经被问过很多次了,但我无法解决。
我试图在 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")
,但它仍然不起作用。
编辑:
将 url 更改为上传到 google 存储桶的图片链接也不起作用。
background-image: url("https://storage.googleapis.com/#####");
最佳答案
以下更改应该可以解决问题:
background-image: url("/assets/benchmark.PNG");
<link rel="stylesheet" href="/assets/test.css">
<div class="hero-image">
sdfdsfbfd <br/>sdfdsfbfd <br/>sdfdsfbfd <br/>sdfdsfbfd <br/>
</div>
关于html - Cloud9 IDE + Rails App : CSS Background Image Not Showing on . erb 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50997753/
我是一名优秀的程序员,十分优秀!