我正在尝试在我的网页上添加背景图像,当我使用平面html时它可以工作,但现在我正在将其集成到我的rails应用程序中。
我正在使用此代码将图像嵌入到我的 rails 应用程序中
<div class="jumbotron" style="background-image:
"url(image-url('lines3.png')";
background-repeat: repeat-x;
background-position: center bottom">
它不会在日志中抛出任何异常,但也不会显示图像,可以建议
您应该将"background-image:"url(image-url('lines3.png')";
更改为"background-image:"image-url(image-url('lines3.png')";
http://guides.rubyonrails.org/asset_pipeline.html#css-and-sass
或者你可以试试: background-image: url(<%= asset_path 'lines3.png' %>)
你可以这样做
<div class="jumbotron">
</div>
.CSS
<style>
.jumbotron{
background-image: image-url('lines3.png');
background-repeat: repeat-x;
background-position: center bottom;
}
</style>