Over the years I have tried several times to find a stable way to add two backgrounds to a site. It may be that I want a horizontal background that may have a gradient and a vertical background that is 100% tall and adds a slight shadow to the edges of the site.
This is not an easy effect to create. Only Safari can support multiple background images in a single element. Why? I have no idea, it would be fantastic if you could easily blend multiple images, there is so many cool things you could do with less code. Anyway, I found an article on Sitepoint that talks about styling the html and body elements and I realized two background images could be done via that method. (http://www.sitepoint.com/blogs/2009/02/11/styling-the-html-and-body-elements/) The strategy they outline is actually something I have tried in the past and was uncessful but I probably did something wrong, not realizing it was me and not the element I was styling.
I haven’t tried this yet, but their strategy is to style the html tag with one background image and the body with the other. This should allow you to create dual effects. I don’t know how it will render in all browsers but I am excited to try it out.
Here is their code that can create a single fixed column 100% high.
html { background-color: #333; } body { background-color: #fff; width: 750px; margin: 0 auto; } |
You can style the columns however you want. Both could be a 100% wide with repeating background images etc. I will include more examples once I have fully tested this technique for cross browser compatibility. If you try it out let me know how it works!
Why have I never heard of this idea before? Why did I never think of that.
All this time we have been skipping over the html tag to style just the body.
I think that Sitepoint guy needs a medal.
I look forward to hearing about your own tests Ryan.
I know! Same here, I am hoping to use it here in a couple days on a production website.
I have been using that same method on the site I am developing at the moment.
I am using {
}
Nice article
to Sheldon
zero it’s already zero it can not be different
I mean that you can remove a “px”
And also how can you use completely different typeFonts?!
Lucida Grande and Helvetica and so much more Verdana are completely different fonts
Nice. Really helpful. you also check as follows;
http://haacked.com/archive/2005/04/04/2541.aspx
http://www.webcredible.co.uk/user-friendly-resources/css/css-tricks.shtml
http://www.cherny.com/webdev/11/dual-background-images