Main Content & Multiple Columns
Main Contet & the Aside
The content area and sidebar are going to be aligned beside each other. Traditionally you would do this by using floats, but in CSS3 we are going to use tables!
"What?! Tables?" you might ask and look confused. You probably learned years ago that using tables for web layout is a big no-no, and it still is. You should never use the table-element to mark up a layout. However, in CSS3 we can make elements behave like tables without it ever showing in the markup.
To start off with, we're going to need some divs to group the sections in a more logical manner.
< div id="content">
< div id="mainContent">
< section>xxxx xxxxxx xxxx< /section>
< section id="comments">
xx xxxxxxxxx
< /section>
< form>xxx xxxxxx x< /form>
< /div>(end of main content div)
< aside>xxx xxxxx< /aside>
< /div> (end of content div)
Everything still makes sense semantically, but now we can style it. We want the
#content div to behave like a table, with two table cells,
#mainContent and
aside. With CSS3, this is very easy:
display: table;
}
#mainContent {
display: table-cell;
width: 620px;
padding-right: 22px;
}
aside {
display: table-cell;
width: 300px;
}
That's all! No more floating, faux column background images, clearing or collapsing margins. By setting the property declaration to table-cell the elements of the page behave as if they were cells of a table.
The aside element is to the side of the page, as its name suggests. It is within the content of the content div but outside of the main content div thus removing it from the flow of the main content.
By making the elements behave like a table, its makes it much easier for us to create visually apealing layouts.
Comments
Dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.
Click here to learn how you can now apply a Zebra effect to the comments without using JavaScript.
This is an ideal section to explain how you zebra stripe the comments using the new css3 styles.