I have followed advice from other topics but can't get it to work. I want to set a background image.
my scss file is custom.css.scss and code is body
{ background-image: url("back.png"); }
back.png
is located in app/assets/images
custom.css.scss
is located in app/stylesheets
i have no problem getting back.png to work through the asset pipeline in my html pages with
<%= image_tag "back.png" %>
#SCSS
body {
background: {
image: asset_url("back.png");
}
}
#SASS
body
background:
image: asset-url("back.png")
I would strongly recommend using SASS
over SCSS
.
The simple difference is that SASS doesn't have any semicolons
or brackets
. Other functionality is the same.
--
Although asset_path
works, we've found it much more effective to use asset-url
(asset_url
in SCSS
)
use it with the asset pipeline
body { background-image: url(asset-path('back.png', image)); }
more functions at the documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With