New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

Start learning with our library of video tutorials taught by experts. Get started

CSS: Page Layouts
Illustration by

Building flexible layouts: Solution


From:

CSS: Page Layouts

with James Williamson

Video: Building flexible layouts: Solution

Welcome back! I hope you had fun working on the flexible version of the desolve.org layout. Now, flexible layouts are difficult, especially the more complex your pages get, so don't feel bad if a few of the steps didn't work out the way you wanted them to. Let's go through our finished code together, and then we can compare the results. So I have the index and the main.css files open, so index.htm, main.css, and you can find these in the finished_files directory of 06_06. And of course the CSS one is in its own little directory there, _css. Okay.
Expand all | Collapse all
  1. 4m 20s
    1. Welcome
      54s
    2. How to use the exercise files
      3m 26s
  2. 1h 39m
    1. Box model review
      8m 47s
    2. Calculating element dimensions
      11m 11s
    3. Understanding margin collapse
      7m 59s
    4. Calculating em values
      7m 41s
    5. Calculating percentage values
      7m 51s
    6. Normal document flow
      13m 3s
    7. Controlling element display
      8m 53s
    8. Using CSS Resets
      7m 11s
    9. Fixed, fluid, and responsive layouts
      9m 9s
    10. CSS debugging tools
      6m 46s
    11. Using the Firebug Inspector and the WebKit Web Inspector
      11m 5s
  3. 53m 15s
    1. Page design workflow
      3m 6s
    2. Page design tools
      4m 56s
    3. Determining page structure
      7m 18s
    4. Creating image assets
      8m 58s
    5. Creating initial page structure
      7m 3s
    6. Adding meaning with classes and IDs
      5m 23s
    7. Structuring content with HTML5
      6m 6s
    8. Building internal structure
      10m 25s
  4. 1h 36m
    1. Floating elements
      7m 50s
    2. Clearing floats
      7m 28s
    3. Containing floats
      7m 50s
    4. Clearfix technique
      10m 38s
    5. Floating inline elements
      14m 34s
    6. Two-column floated layouts
      8m 17s
    7. Three-column floated layouts
      11m 30s
    8. Column height considerations
      7m 3s
    9. Creating equal-height columns
      10m 42s
    10. Floats: Lab
      5m 25s
    11. Floats: Solution
      5m 21s
  5. 51m 42s
    1. Relative positioning
      7m 59s
    2. Absolute positioning
      8m 59s
    3. Fixed positioning
      4m 23s
    4. Controlling stacking order
      8m 31s
    5. Clipping content
      8m 21s
    6. Controlling content overflow
      5m 38s
    7. Positioning elements: Lab
      3m 59s
    8. Positioning elements: Solution
      3m 52s
  6. 48m 46s
    1. Design considerations for fixed layouts
      3m 28s
    2. Establishing the layout grid
      7m 57s
    3. Defining column spacing
      9m 30s
    4. Applying the grid through CSS
      8m 56s
    5. Creating grid-based assets
      8m 26s
    6. Grid design resources
      6m 22s
    7. Building fixed layouts: Lab
      4m 7s
  7. 44m 35s
    1. Designing for flexible layouts
      2m 30s
    2. Calculating percentage values
      8m 45s
    3. Setting flexible width values
      6m 6s
    4. Making images flexible
      8m 10s
    5. Setting minimum and maximum widths
      7m 24s
    6. Building flexible layouts: Lab
      4m 53s
    7. Building flexible layouts: Solution
      6m 47s
  8. 49m 36s
    1. Responsive layout overview
      3m 49s
    2. Using media queries
      7m 16s
    3. Organizing styles
      8m 39s
    4. Making content responsive
      8m 33s
    5. Mobile design considerations
      7m 32s
    6. Building responsive layouts: Lab
      4m 23s
    7. Building responsive layouts: Solution
      9m 24s
  9. 1h 22m
    1. Creating multi-column text
      6m 36s
    2. Using borders to enhance design
      13m 59s
    3. Rounding corners
      6m 56s
    4. Adding drop shadows
      10m 35s
    5. Working with opacity
      6m 8s
    6. Utilizing the background property
      15m 5s
    7. Working with CSS sprites
      7m 58s
    8. Enhancing page design: Lab
      6m 22s
    9. Enhancing page design: Solution
      8m 38s
  10. 6m 25s
    1. Additional resources
      6m 25s

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
please wait ...
CSS: Page Layouts
8h 57m Beginner Feb 07, 2012

Viewers: in countries Watching now:

CSS: Page Layouts introduces basic layout concepts, gives advice on how to create properly structured HTML based on prototypes and mockups, and goes into critical page layout skills such as floats and positioning. Author James Williamson shows how to combine these techniques to create fixed, fluid, and responsive layouts. Designers are also shown how to enhance their pages through the creative use of CSS techniques like multi-column text, opacity, and the background property. Exercise files are included with this course.

Topics include:
  • Reviewing the box model
  • Calculating em and percentage values
  • Controlling how elements display
  • Creating fixed, fluid, and responsive layouts
  • Structuring content with HTML5
  • Floating elements
  • Using relative, absolute, or fixed positioning
  • Defining column spacing
  • Creating grid-based assets and layouts
  • Considering mobile-design-specific issues
  • Working with multi-column text
  • Enhancing page design CSS Sprites
Subjects:
Web Web Design
Software:
CSS
Author:
James Williamson

Building flexible layouts: Solution

Welcome back! I hope you had fun working on the flexible version of the desolve.org layout. Now, flexible layouts are difficult, especially the more complex your pages get, so don't feel bad if a few of the steps didn't work out the way you wanted them to. Let's go through our finished code together, and then we can compare the results. So I have the index and the main.css files open, so index.htm, main.css, and you can find these in the finished_files directory of 06_06. And of course the CSS one is in its own little directory there, _css. Okay.

So I am just going to start with the steps and work my way down. I'm first going to scroll down in the finished_code to about line 167 or so. I gave the body a width of 90%, and then I gave it a maximum width of 1180 and a minimum width of 860. I am guessing your values probably differ from mine a little bit. That's one of the things about setting a minimum- and a maximum-width value. Generally, a lot of times, it just goes down through personal preference. But I did find that below 860 my layout broke, for a number of different reasons.

I am going to switch over to the browser here and I notice that once I started getting below this value, the navigation really started to run into each other. You can see that the centering of the navigation is still a little off right here, but it got even more off the further down I went. So at about 860 pixels, I decided to sort of freeze it at that point. All right! Now going back into the code, I am going to scroll down a little bit down to the article and the aside. I noticed that the widths are set to the values that I gave you up in the comments, 70.1 for the width for the article, 3.9% padding for both of them.

The article of course is padding to left, because it's the left-hand column; and the aside has padding placed on the right, because it's the right-hand column. Remember, we don't really need to specify any space between the two of them because we're letting the layout itself sort of form that space. So that's something that we don't need to do. Now, I also told you to go down and in the mainNav banner and header elements, go ahead and line up their content with the content of these columns. And if I scroll down to line 199, you can see for the header, all I had to do was place padding-left of 3.9%, because they're all top-level elements.

Same thing for mainNav. About line 237 or so, you can see that has a padding-left of 3.9%. And then the banner selector, which is a little bit further down here, around 295 or so, it has a padding-left of 3.9%. So because these were all top-level elements, meaning they're sitting right inside the body tag, I didn't need to do any further calculations on them. I could just go ahead and use the exact same padding values that the columns and cells were using. Had they been nested inside of them, I would have had to recalculate those values. Now, speaking of that, those two news items, if I go back into the browser of course, these two news items right here that are floating side by side each other, you were tasked also to find out the padding values, the margin values between them, and the width of them, again so that you can arrive at sort of equal spacing between all of those elements.

Now, this is totally a judgment call. You probably did a lot of tweaking, and your values might not necessarily match mine, and that's okay as long as you're happy with the results. So if I scroll down, I can find, on line 360, the news selector for this. Now, you'll notice that for both of these, I used a width of 44%, and I used a padding on both sides of 2%, on the left- hand side of 2%, the right-hand side of 2%. Add up to a total width for both these elements of 48%, which of course is going to leave about 4% space between the two of them, which is why the margin-right is set to 4%.

Now, it doesn't matter that your values match mine precisely. You could use some decimal points. Maybe you did 45% for the width, or 48%. It doesn't really matter. As long as you're comfortable with the spacing and you like the way that it looks, that's fine! What's important here, however, is that all those values add up to 100%, so that you're taking up all the available space within the column. Now, the contest images, the last task that I gave you, to make sure those images displayed at their natural size if they were able to and then scale down if the browser was scaled down, that was a little trickier.

I played a little trick on you there. That's a little harder than it seems, because in the previous exercise where we did that, remember we set the maximum width to 100%. But the maximum width there, in order for it to be that size, is not 100%. Let me show you what I mean. If I go down to, all the way down, let's go down to about line 650 here in our code, I can find content image. Now, here is how I solved it. For these content images, I placed their maximum width at 82%. All right! How many people got 82%? Show of hands. A couple of people. Anybody, 82%? So how in the world did I get 82% and I didn't just give it 100%? Well remember, 100% would have made it fill the entire right-hand column, which is going to scale it up, and it's not the way I want that to look.

So I placed two images side by side just like I did in the previous fluid images exercise, and I began playing around with the width until I got a width value that was equal to the 200 pixels of width that the image actually was, and that turns out to be 82%. So I am saying, okay, you can be your normal width, but any other time I want you to be 82% of that column, and that way it's going to maintain that sizing-spacing relationship with all the other elements. Now, of course I also had to modify the code, so if I went back to index and took a look at these images, you can see that I got rid of the height property.

Now I left the width property in here. Some of you probably stripped it out. If you did, that's fine. That's no problem. So essentially, what this is doing now is it's telling the browser, hey! I need to be 200 pixels wide. And then the CSS is overwriting that, and saying okay, yeah, 200 pixels is fine as long as you're not above 82% of the column width. And that's how that's working. So it will appear at 200 pixels wide if it can. It's going to calculate its height based on the aspect ratio, and that it will never be wider than 82% of the column. So now, when we scale this, the images display at their natural size until you start scaling it down, and then they maintain that relationship at 82% the entire time.

Okay. Of all the labs I've given you, I'll be honest with you, this one took the most time for me to actually put together. To convert the fixed version of the deslove.org site that I was working with before this to the fluid versions, I had to make significant changes to the overall layout, and in more than just one area. So if you want to take this lab a little bit further, if you really want to dig it apart, compare this layout to the finished layout in our floats lab, which is the previous lab where we used the fixed version of this layout. See if you can identify all of the formatting changes from the fixed layout to this one, and there a lot of them, and think about why they were necessary in order for this fluid layout to work.

Now, that should give you some insight into some of the issues that you'll need to think about as you begin to create fluid layouts in your own work.

There are currently no FAQs about CSS: Page Layouts.

 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

join now Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed CSS: Page Layouts.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Are you sure you want to delete this note?

No

Notes cannot be added for locked videos.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.