Reputation: 4052
I submitted the question below a few months ago where I had a problem with a background image not working when I upgraded my Rails 3 application to Rails 4. The solution was to use scss and precompile the production assets.
Rails 4 - Background Image Appears in Localhost but not in production
I have a slightly different problem that I need help with. I have a landing page with a different format than the main website. When I do this I normally code my CSS code in my layout page. In my situation I would add style tags to landing.html.erb. I want to set a background image for html and stretch it across the entire screen only for the landing page. I have tried two things but cannot get this working.
I first tried adding the following code in landing.html.erb in the style tag:
html {
background: asset-url("SplashPage-Image.jpg");
background-repeat: no-repeat;
}
I then tried to implement something similar to the solution on the previous question.
application.css.scss
@import 'landing';
landing.css.scss
html {
background: asset-url("SplashPage-Image.jpg");
background-repeat: no-repeat;
}
In both cases when I look at the source I can find the code when I look at the css files but the image does not show up. I have tried rake assets:precompile RAILS_ENV=production
and rake assets:precompile
. It makes no difference. I have found a good number of questions on Stack Overflow regarding background images but none of them deal with my specific situation.
Any help would be appreciated. I will keep looking.
Upvotes: 2
Views: 644
Reputation: 711
Have you tried background: url("SplashPage-Image.jpg"); no-repeat center center fixed;
?
Upvotes: 1