![]() |
|
|
Use CSS floats to create a three-column web ayou |
Post Reply
|
| Author | ||
manu
Bronze Member
Joined: 04 Jul 07 Location: India Posts: 73 |
Quote Reply
Topic: Use CSS floats to create a three-column web ayouPosted: 16 Feb 09 at 5:49pm |
|
|
Use CSS floats to create a three-column page layout The basic layout consists of five divs, one each for the header, footer, and the three columns. The header and footer divs span the full width of the page. The divs for the left and right columns are each fixed-width and use the float attribute to push them over to the left and right sides of the browser window. The div for the middle column actually spans the full width of the page, and the contents of that column flows between the left and right column divs. Since the middle-column div doesn't have a fixed width, it's free to expand and contract as needed with changes in the browser window. Padding attributes for the left and right side of the middle div keep the contents arranged in a neat column, even if it extends below the bottom of one of the side divs. HTML Code
Css code
Explanation The clear: both declarations in the div#header and div#footer styles ensure that floated divs don't encroach on the header and footer.The float: left declaration in the div#left style pushes the div over to the left. The width: 150px declaration sets the column to a fixed width, but you can easily substitute a percent value instead. In the div#right style, the float: right declaration pushes the div to the right. In this case, the floats push the divs all the way out to the left and right edges of the browser window. However, if these divs were enclosed within another div, the floats would push them to the edges of the containing div instead. In the div#middle style, the absence of a clear declaration allows the contents of the middle div to flow up between the side columns. The padding: 0px 160px 5px 160px declaration sets padding on the left and right sides to allow room for the 150px-wide side column divs, plus an extra 10px of breathing room. |
||
![]() |
||
Post Reply
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |