04.06.2013 Views

Head First HTML with CSS

Head First HTML with CSS

Head First HTML with CSS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ackground images<br />

Adding a background image<br />

You’re almost there. What’s left? We still need to get the white “guarantee star”<br />

graphic into the paragraph and work on the border, which is a solid, black line.<br />

Let’s tackle the image first.<br />

If you look in the “chapter10/lounge/images” folder, you’ll find a GIF image called<br />

“background.gif ” that looks like this:<br />

Now, you just need to get that image into your paragraph element, so you’ll be<br />

using an element, right? Not so fast. If you’re adding an image to the<br />

background of an element, there is another way. Using <strong>CSS</strong>, you can add a<br />

background image to any element using the background-image property.<br />

Let’s give it a try and see how it works:<br />

.guarantee {<br />

line-height: 1.9em;<br />

font-style: italic;<br />

font-family: Georgia, “Times New Roman”, Times, serif;<br />

color: #444444;<br />

border-color: black;<br />

border-width: 1px;<br />

border-style: solid;<br />

background-color: #a7cece;<br />

padding: 25px;<br />

margin: 30px;<br />

background-image: url(images/background.gif);<br />

}<br />

404 Chapter 10<br />

This image is a simple star-like<br />

pattern in white against a<br />

transparent background. Notice<br />

that it also has a matte around<br />

it that matches the color of<br />

the background.<br />

Here are the properties you added<br />

in the exercise on the previous page.<br />

Add this to your <strong>CSS</strong>, save, and reload your page.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!