how to add background image in ruby on rails

how to add background image in ruby on rails

In This Post We Discuss add background image in ruby on railsruby on rails background image, rails 6 images, rails css asset path, rails scss image url, asset url rails, And background bootstrap responsive.
add background image in ruby on rails
add background image in ruby on rails

To Add background image Ruby on Rails app using Bootstrap CSS

It is very simple to do, and it is.  Although it took me half an hour of searching on the internet and impliment with the code to get it to work.  Many sites shows what code to write, but doesn't showed where to put the code.  Here is what I did, using Rails 4 and Bootstrap 3.You May Copy It...

Code Sample #1
background-image:url('assets/image/new.jpg');{codeBox}

Code Sample #2

background-image: url(/assets/images/new.jpg);

background-image: image-url("new.jpg");{codeBox} 

Code Sample #3

background: url('../new.jpg');{codeBox} 


Edit: Only Two things

  1. As per my point of view, I utilized the tag “image-URL” rather of just “URL”. I believed that this now permits the image to be loaded in the Rails asset channel. 
  2. you don’t require the ‘/assets/’ in front of the image path. Rails and the asset channel will automatically check in the ‘app/assets/images folder, so you don’t require any leading path unless you create a folder within that folder.

background-size stripe creates the image fit precisely to its parent attribute, in this case, the body of the HTML document.

Also note, only containing the slash “/” in front of the image file title can make this not work.

Hope this article on " how to add background image in ruby on rails " is helpful to you!

 

*

Post a Comment (0)
Previous Post Next Post