Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Although no set standard has emerged for CSS based layouts, one of the most common models is to float container level elements and then position or float the nested contents inside of these containers. Our Cheek Chastain site, will use a fixed two column floated layout with a header and a footer element and before we begin working on it site, let's do a sample layout, so that we understand the basics of using this technique. So I have the example file two_column_float_review open and you can find that in the Chapter 3 site if you are following with us. Notice that we have a header and then we have an area here in the sort of teal blue that is a content area, and below that we have a sidebar, and below that we have a footer. I am going to switch over to Code view, so that we can see the content itself. Notice that we have a wrapper div tag that surrounds the entire content and that's again fairly common. We have a header div tag, a content div tag, followed by a sidebar div tag, and then we have an empty div tag whose id is clear. Now that's not exactly structural and you could say that it doesn't really fit within the separation or presentation of the structure but putting some non- semantic markup in your layouts every now and then is almost going to be required. And of course below that we have the actual footer itself. So I am going to go back to Design view and I will open up my CSS Styles panel and we have already got a few selectors in here that are helping us type background colors and things to identify this. What I want to do right now is start working with the content area and a sidebar area and actually getting them into a two- column layout. So I will grab my content div tag and I will add a property to it and I am going to float it to the left and as I do that nothing really happens. That's because the fact that the sidebar, remember, is going to be coming up underneath it and so that orange background now sort of stretches up underneath that. So I am going to select my sidebar selector and I will add a property to it as well and since I want the sidebar to appear to the right of the content, I will go ahead and do a float on that and I will float that to the right. Just like that, the content area is floating to left and the sidebar is floating to the right. Now the wrapper is actually 600 pixels wide and if we look at our content div tag, it is 380 pixels wide. Our sidebar is 200 pixels wide. So together they are 580 pixels wide, which leaves a gutter of 20 pixels in between the two of them. Now that's actually a very common technique because the last thing you want to do is start drawing a lot of margins or padding on your container elements. In order to control this space in between floated elements, it's better to control their widths so you get this virtual gutter then it is to try to assign that value using margins. That can negatively affect a lot of layouts because certain browsers handle floated margins differently. Internet Explorer for example, has a very common bug in version 6 called the double floated margin bug. If you give a margin to a floated element and the margins on the same side, so if I say give a margin right to a right floated element, then Internet Explorer 6.0 doubles the margin for just no good reason. So there are ways of fixing that but easiest way to fix it is just don't do it. So if I want to contain the elements inside of these floated elements, if I want to move them away from the edge, I will actually put padding on the interior elements rather trying to pad or put margins on the container elements. Now that we understand the basics of using floats for layout, we will next focus on structure and the content of our Cheek Chastain Gallery site.
Get unlimited access to all courses for just $25/month.Become a member
58 Video lessons · 60088 Viewers
61 Video lessons · 92734 Viewers
82 Video lessons · 104195 Viewers
56 Video lessons · 107192 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.