CSS 3 Background Resizing
So one thing I really like is backgrounds images that fill the whole viewpoint and then resize as you resize the browser window. This effect use to be hard to do having to use Flash or a lot of Javascript. Not any more with the CSS 3 on the horizon you can now do it using just 1 attribute ( or 4 because at current all browsers have there own version of CSS 3 attributes ). The new attribute called background-size allows you to tell the browser how to manage the background images size. The three options for the full viewpoint background that resize with the browser are.
html { background: #FC0 url('background-image.jpg') no-repeat center center fixed; /* * CSS Background Size */ /* Cover */ background-size: cover; /* Contain */ background-size: contain; /* 100% */ background-size: 100% 100%; }
Fills the viewpoint making sure the whole image stays in view and stretching the image proportional. So if the user has the view point set in a different aspect ratio to the background image you will see the background come through as bars on the top and bottom or both sides. Imagine setting your background to black and then creating a widescreen (16:9) image and view it with the view point set to 4:3. The result would be similar to watching a widescreen movie on a non-widescreen TV you would get black bar.
Example : http://labs.dotmh.com/examples/CSS3/Background/contain.html
This has a similar effect to contain but this time the image fills the whole background using the shortest size. This time instead of seeing the background colour come through the image is cropped to the viewpoint , this only happens when the view point is a different aspect ratio to the image.
Example : http://labs.dotmh.com/examples/CSS3/Background/cover.html
This fills the entire viewpoint , ignoring aspect ratio i.e. non-proportional. So if the browsers viewpoint is of a different aspect ratio to the image then the image would appeared stretched.
Example : http://labs.dotmh.com/examples/CSS3/Background/100percent.html
By the way I am aware of the grammar mistake(s) in the examples but I don't have the original PNG. If I get a chance I will re-do it without the mistakes. :)