Lesson 3:: Introduction To CSS Layout
Lesson 3:: Introduction To CSS Layout
Lesson 3:
Introduction to CSS Layout
8/4/2014
8/4/2014
CSS review
We have covered CSS tag styles and CSS class styles. There is a
third category of styles called ID styles.
An ID style is virtually identical to a CSS class style with one major
exception. Whereas a CSS class can be reused throughout a page, a
CSS ID can only be used once per page.
CSS Borders
Using the CSS border property you can apply borders of various
colors, styles and widths to any element on the page.
border-color, border-style and border-width are the
relevant properties.
You can also apply borders to any (or all) of the four sides of a box.
For layout purposes this can be useful for visually separating
sections of the page from each other.
The default value for a border is solid, but you also have other
choices including dashed and dotted.
8/4/2014
CSS Margins
Within the box model, the space on the outside of the box is the
margin.
CSS margins are always invisible and the background-color of the
box does not apply to the margins.
Margins are typically used to add space between elements on your
page. Typically, margin values are expressed in CSS shorthand.
margin: 5px 10px 0px 20px;
In CSS shorthand you start with the first value (which is the top
margin) and then move clockwise: so the top margin is 5px, the right
margin is 10px, the bottom margin is 0px and the left margin is 20px.
CSS Padding
Whereas CSS margins apply space around the outside of a box,
CSS padding add space to the inside of a box.
Padding is a simple way to add equal amounts of space inside a box.
However, like margins, you can also specify how much space you
want to add for the top, right, bottom and left.
Typically, padding values are expressed in CSS shorthand.
padding: 5px 10px 0px 20px;
One important consideration for padding is that it increases the
effective width of a box.
8/4/2014
The CSS clear property becomes a useful tool for creating CSS
layouts. The property has three possible values:
clear: left
clear: right
clear: both
Objects that have the clear property applied to them are not allowed
to have floated objects on the specified side. This can be useful for
page elements, such as footers, which you generally do *not* want to
be positioned next to a column.
#footer {
backgroundimage:url(images/footer_background.jpg);
}
The background-image property references an image and places it
within the specified style; in this case an ID for the footer.
8/4/2014
Styling Hyperlinks
The default appearance of hyperlinks is a blue underline (if the link is
unvisited) or a purple underline (if the user has already visited the
link). Many designers prefer modifying this default style to better fit
the appearance of their page. Hyperlinks fit inside a unique category
called pseudo-classes, and styling them requires an understanding of
their behavior.
a:link
This is the default style of links before they have been clicked by the
user.
a:visited
}
A value of no-repeat only displays the image one time. The other
values are repeat-x which will tile the image horizontally, and
repeat-y which will repeat an image vertically. If you are specifically
creating an image designed to be tiled, you will need to use an image
editor such as Photoshop to create this graphic.
This is the style of links after they have been clicked by the user.
a:hover
This is the style of links as the user places their cursor over them.
a:active
Summary
In this presentation you learned:
The fundamentals of creating a two-column fixed-width layout
The role of a CSS reset file and how to use one
How to work with with HTML divs and CSS IDs
How to work with the CSS float property
How to work with the CSS clear property
How to work with background images
How to work with hyperlinks
(Repeat the above rules for a:hover and a:active but change the color
value)