adding background image in style rails 4

时间:2015-06-15 14:30:56

标签: ruby-on-rails twitter-bootstrap ruby-on-rails-4 asset-pipeline

I am trying to add background image on my web page, it was working when I was using plane html, but now I am integrating it to my rails application.

I am using this code to embed the image in my rails application

  <div class="jumbotron" style="background-image:                                                                                                                                                            
                                    "url(image-url('lines3.png')";                                                                                                                                             
                                      background-repeat: repeat-x;                                                                                                                                             
                                      background-position: center bottom">

It is not throwing any exception in logs but not showing the images as well, can suggestions

2 个答案:

答案 0 :(得分:3)

You should change "background-image:"url(image-url('lines3.png')"; into "background-image:"image-url(image-url('lines3.png')";

http://guides.rubyonrails.org/asset_pipeline.html#css-and-sass


Or you can try with: background-image: url(<%= asset_path 'lines3.png' %>)

答案 1 :(得分:0)

You can do like this

<div class="jumbotron">
</div>

CSS

<style>

.jumbotron{
  background-image: image-url('lines3.png');
  background-repeat: repeat-x;
  background-position: center bottom;
  }

</style>