URL
value for the image itself, you have two other basic parts of the attribute: (1) some values for height, width, and corner sizes, and (2) a statement of how the images are rendered. In this example, I'm using the stretch
rendering option, which as you can guess merely stretches the images as needed to fill the space alloted to the box--in this case, this paragraph. The border-image style attribute for this paragraph is:
"-webkit-border-image: url('/images/brdrs2.png') 22 stretch; border: solid #E2E6CE 2em"
The first set of values took a bit of guesswork on my part, working from the example at CSS3.info. Basically, what you need to consider in designing or choosing an image is that the image needs to parse into three repeatable components: One for the corners, one for the horizontal stretch part, and one for the vertical stretch part. To break this down into a simple example so I could begin with something worth sharing, I followed CSS3.info's lead and went with a square image, with 9 equal square parts total and 3 equal square parts for the three components I needed. Each component is 22 pixels square, so the only value I need in the CSS is 22
, a shorthand like saying padding: 5px
if you want 5 pixels of padding on all four sides.
The final piece of the puzzle is one that took me the longest to discover: For a border-image attribute, you still need a border
attribute, to control the width of your border. I don't think the border style's other attributes are needed, but you do need to specify the border width. This paragraph uses a 2em border width, whereas the next one uses 4em.
It's not pinin', it's passed on! This parrot is no more! It has ceased to be! It's expired and gone to meet its maker! This is a late parrot. It's a stiff! Bereft of life, it rests in peace! If you hadn't nailed it to the perch it would be pushing up the daisies! It's rung down the curtain and joined the choir invisible! This is an ex-parrot!
round
attribute instead of stretch
. It uses the same image as before, but takes in the full 66-pixel-square graphic, ringing the paragraph in a repeating pattern. In this example, I say round round
because I want the repeating pattern on both the top/bottom (the first round
) and left/right (the second one) sides.The style attribute for this paragraph is:
"-webkit-border-image: url('/images/brdrs2.png') 66 round round; border: solid red 2em"
In a repeating pattern like this, the values of both the padding and width are significant; otherwise, you'll get broken patterns. After the URL
attribute, the 66
tells the style to use the full 66-pixel width of the image as the pattern to repeat. You can use whatever portion of the pattern makes sense for a given design. As in the preceding example, the border declaration is also quite important: You can use the line width value to change the overall size of the pattern. The next example uses a 1em width instead of 2em.
As in the border
property itself, border-image
has both full and shorthand forms. You can use multiple images (up to three, I believe) for the full border, whereas this example uses only one. The next attribute (size) can have up to four values: top, right, bottom, left. Here, I use 66
because it's the same for all four sides. I discovered that using this kind of border pretty much requires you to specify an appropriate width for the paragraph or div, to avoid as many mis-matched patterns as possible, since the implementation in WebKit/Safari doesn't force an even number of pattern repetitions.
Compared with border-image, applying a box-shadow to a paragraph is intuitive, working just as you'd expect it to. In its basic form, the style takes four attributes: (1) x distance, (2) y distance, (3) size of blur in pixels, and (4) the shadow color. Here's the style used for this paragraph:
"-webkit-box-shadow: 2px 2px 11px #888"
You can use negative values for x and y, to reverse the direction of the shadow, and a small blur value results in a sharper edge. It's also terrific to know that the box-shadow will follow adjust itself to the curves of the CSS3 border-radius style, which has been implemented both in Safari and Firefox now. The example below shows a box-shadow on a paragraph with a defined border-radius, as well as a regular old 1pt border.
Incidentally, this article's section titles, along with their circled numbers, are made using a combination of the CSS3 box-shadow, border-radius, and opacity styles.
Good morning. I'm sorry to have kept you waiting, but I'm afraid my walk has become rather sillier recently, and so it takes me rather longer to get to work.Now then, what was it again? "Well sir, I have a silly walk and I'd like to obtain a Government grant to help me develop it." I see. May I see your silly walk? "Yes, certainly, yes..." (After his demonstration concludes...) That's it, is it? "Yes, that's it, yes." It's not particularly silly, is it? I mean, the right leg isn't silly at all and the left leg merely does a forward aerial half turn every alternate step. "Yes, but I think that with Government backing I could make it very silly."
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.