I have a custom style in my css for a background image I want to apply:
.specialbg {
background-image: url('http://i.imgur.com/XMuKF.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
I want to apply this style to my body element in HAML, but I’m not sure how the arguments are setup. I’m thinking that the following should work:
%html
%head
%body
.specialbg
But it doesn’t. I’ve read the haml styling reference manual, but can’t see where I’m wrong — I’ve just adopted haml, and I’d appreciate any help or pointers!
Stack Q’s I’ve referenced:
Background images do not render on Ruby on Rails application
To add the class to your body element, you would just append the class to the tag like this:
It could be a typo in your example, but the way your example is set up, you are putting your body tag within the head tag
If you put the
.specialbgclass on its own line, it will create a div inside of your body tag withclass='specialbg'