background-size
style gives you another way of utilizing images as backgrounds to HTML elements. Up to now, you could tile the image or have it display only once without repeating. Background-size additionally will let you scale the image to whatever size you like. You can use it in combination with existing background image CSS styles. Now this will prove a very useful trick! Web designers have long been able to make an <IMG>
image stretch using percentage specifiers for height and width but had to concoct elaborate workarounds in order to implement scaling backgrounds.T.F. Gumby: Are you the brain specialist?
Specialist: No, no, I am not the brain specialist. No, no, I am not... Yes. Yes I am.
T.F. Gumby: My brain hurts!
Specialist: Well let's take a look at it, Mr Gumby.
(Gumby specialist starts to pull up Gumby's sweater.)
T.F. Gumby: No, no, no, my brain in my head. (specialist thumps him on the head)
Specialist: It will have to come out.
T.F. Gumby: Out? Of my head?
Specialist: Yes! All the bits of it.
As if being able to resize backgrounds weren't enough, with Safari you can now also take advantage of the CSS3 style that lets you use more than one background image at a time! Naturally, you can position each image with existing CSS styles, for truly mind-expanding possibilities.
In the example here, I'm using three images, one anchored at the top, one at the bottom, and the third filling in the middle vertically. I could have achieved the same design previously using three separate <DIV>
elements, each with its own background image. But now I can do it with one HTML element instead. I did find it a bit tricky getting the middle image to tile appropriately, since apparently the "background-clip" attribute doesn't work quite right in WebKit yet. The middle element is asked to tile vertically 100%, but I couldn't find a way to let it know that it shouldn't expand into the area occupied by the top or bottom images using the CSS3 properties. However, I was able to use background-clip's "border" and "content" values by defining a transparent border at the top and bottom of the text box, and by using extra left and right padding values around the text.
Below you'll see a reprise of the Background-Resize box style, as embedded in a box with multiple background images.
TV Host: Miss Anne Elk, who is an expert on di...
Anne Elk: N' n' n' n' no! Anne Elk!
TV Host: What?
Anne Elk: Anne Elk, not Anne Expert!
TV Host: No! No, I was saying that you, Miss Anne Elk, were an , A-N not A-N-N-E, expert...
Anne Elk: Oh!
TV Host: ...on elks - I'm sorry, on dinosaurs. I'm ...
Anne Elk: Yes, I certainly am, Chris. How very true. My word yes.
TV Host: Now, Miss Elk - Anne - you have a new theory about the brontosaurus.
Anne Elk: Can I just say here, Chris for one moment, that I have a new theory about the brontosaurus?
Using Firefox, Camino, Opera, Internet Explorer, or earlier versions of Safari/WebKit? (Including the various offspring/siblings of those browsers.) Here are some quick screen grabs of the demos in this section to give you a flavor of what's going on here.