04.06.2013 Views

Head First HTML with CSS

Head First HTML with CSS

Head First HTML with CSS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Adding the basic styles to the elixirs<br />

We’ve got the width out of the way. What’s left to do?<br />

❏<br />

❏<br />

❏<br />

#elixirs {<br />

border-width: thin;<br />

border-style: solid;<br />

border-color: #007e7e;<br />

width: 200px;<br />

}<br />

<strong>First</strong>, we’re going to change the width of the elixirs to<br />

make it narrower.<br />

Next, we’ll knock out some of the styles you’re already familiar<br />

<strong>with</strong>, like padding, text alignment, and the background image.<br />

Then all we’ve got left are the text line heights and the heading<br />

colors. You’re going to see that you need to upgrade your <strong>CSS</strong><br />

selector skills just a bit to get those changed.<br />

Now we’re going to concentrate on some of the basic styles, like the<br />

padding, the text alignment, and also getting that background image<br />

of the cocktail glasses in the elixirs . You’re already familiar<br />

<strong>with</strong> how most of this works, so let’s take a quick look at the <strong>CSS</strong>:<br />

Remember we’re going to apply all this style to the<br />

elixirs so that it only affects the and<br />

the elements it contains, not the entire page.<br />

padding-right: 20px;<br />

padding-bottom: 20px;<br />

padding-left: 20px;<br />

margin-left: 20px;<br />

text-align: center;<br />

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

background-repeat: repeat-x;<br />

The default padding on a is 0 pixels, so<br />

we’re going to add some padding to provide a bit<br />

of space for the content. Notice that we’re not<br />

adding any padding at the top because there’s<br />

already plenty of room there thanks to the<br />

default margin on the heading (look back at<br />

the last test drive and you’ll see there’s plenty of<br />

room above the ). But we do need it on the<br />

right, bottom, and left.<br />

And finally we’re specifying an image to use in the background, in this<br />

case the cocktail image. We’re setting the background-repeat property<br />

to repeat-x, which will tile the image only in the horizontal direction.<br />

We’re doing this step next.<br />

We’re adding some margin on the left to indent<br />

the elixirs from the rest of the page a bit.<br />

This is going to come in handy later...<br />

divs and spans<br />

Use text-align on block elements to<br />

align the text they contain. Here we’re<br />

going to center-align the text.<br />

you are here 447

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

Saved successfully!

Ooh no, something went wrong!