Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Building responsive layouts: Solution

From: CSS: Page Layouts

Video: Building responsive layouts: Solution

I hope you enjoyed working through the responsive-layout lab. Now, creating responsive layouts takes a lot of focus and planning, and just being dropped into the middle of a partial layout like you guys were is a little bit challenging. So let's take a look at the solutions to your tasks and then discuss some of the other responsive features of this particular layout. So I have the index.htm and the main.css opened up from the finished_files directory in the 07_06 folder. And the first thing that you were tasked to do is to create a viewport tag that forces mobile devices to set their viewport width to the actual device width and to set the initial scale at 100%.

Building responsive layouts: Solution

I hope you enjoyed working through the responsive-layout lab. Now, creating responsive layouts takes a lot of focus and planning, and just being dropped into the middle of a partial layout like you guys were is a little bit challenging. So let's take a look at the solutions to your tasks and then discuss some of the other responsive features of this particular layout. So I have the index.htm and the main.css opened up from the finished_files directory in the 07_06 folder. And the first thing that you were tasked to do is to create a viewport tag that forces mobile devices to set their viewport width to the actual device width and to set the initial scale at 100%.

And there is the syntax for that right there on line number 6. A couple of things where people typically make mistakes within the syntax is the comma-separated list of properties here. They might have another set of quotation marks, for example. They may forget the comma. So check out your syntax and make sure that it matches mine in that regard. I'm going to switch over to main.css, and let's go down and take a look at our different media queries. So the first media query was mobile devices, the second one was tablet, and the third one was desktop. So I am just going to scroll down and go through all those different media queries.

So the first one I want to talk about is the mobile styles one. You will notice that one is asking for only screen and a max-width of 480 pixels. I don't want these styles to apply to any screen that is wider than 480. Now, the next one was our tablet styles, and for the tablet styles right here on line 517, you will notice that I set a range of values, a min-width of 481 pixels and a maximum of 768. Now, typically where people make errors here, syntax-wise, is they might use the same value here that they used in the mobile one.

So for the mobile they might have had max-width of 481, or here they might have a min-width of 480. You always want those to be different. If they're the same, that means a condition will exist where both style sheets will be applied, and what's going to happen at that point is you are going to have a lot of styling conflicts. You are going to have lot of things reflowing and not looking the way that they are supposed to. So make sure that all of your media queries have unique ranges of values. Now, the final media query--and I am just going to scroll down a little bit further into our desktop styles-- sets to min-width of 769 pixels, again, one more than the tablet media query.

All right! Going back up into our steps, the next thing that I tasked you guys to do was to hide the unordered list in the tablets and mobile styles and then hide the selector in the desktop styles. So I am going to go down and take a look at those in order. So if I go down, all the way down to 965, to my desktop styles--and actually the finished ones are on about Line 970, because of course we have been adding styles-- you can see that I did this a very simple way.

I created a selector that targets any select element inside of a navigation element, and of course we only have one of those in our site, so that was pretty easy to find. And then I wrote display: none. Now, there are a couple of different ways to do that. You could have done visibility: hidden. The reason I used display: none is because it truly removes it from the page, in terms of spacing, so we don't have to worry about any margin or padding that might be native to that select affecting the elements around it. It truly does remove it from the visual display. Now, it's still in the code, so it's not moving it from the document object model, but it is removing it visually from the page.

And I used the same technique on my tablets and on my mobile devices. And if I scroll up into my tablet styles-- and I use the same selection for both of them, so this selector, where I am targeting an unordered list inside of a nav, inside of an aside, so it's a very specific selector, and I'm telling that not to display as well. So I am using another display: none. Now, it's quite possible that you may have written the selector a little bit differently and still achieved the same results. That's fine. It's quite possible that you used a property other than display: none. If that's working for you, that's fine too.

But be sure that whatever selector or properties that you have used aren't causing any odd spacing issues in that region. That's one thing you want to take a look at. All right! I am going to scroll back up to our last step. And our last step was going into the mobile styles and the tablet styles and replacing the larger preview images in the gallery to the smaller preview images. And if I go down to right about line 430, it's going to be in that region. And you'll notice that whereas before they read philly_banner, now the path is sm_philly_banner.

The same is true of the tablet styles. Now, once again, that's going to request the physically smaller file. It's going to fit that part of the layout better. It's also going to be a smaller resource for downloading. So for phones, for tablets, for those types of devices, I am requesting actually smaller images, which is going to help with overhead, which is going to help with performance. Now, I mentioned that those steps obviously weren't the only things that make this layout responsive. There is a lot that went into planning this particular layout.

As a matter of fact, to be honest with you guys, when I started creating this course and some other material, I planned the responsive site first, because if you try to take an existing fixed site or an existing fluid site and change it into a responsive site, you are in for a world of trouble, because there is so much you need to consider. Responsive sites, in my opinion, are best when they are planned from the ground up. All right! I just want to show you just a couple of other regions in the layout that took a lot of planning and tweaking to make responsive. So when you're finished watching this movie, go back into the finished files and then break down the CSS and the HTML that I have used to style those respective areas and you'll get a better feeling for what it takes to sort of plan and strategize out responsive layouts. All right! So I am going to go just into the browser, and I want you to pay attention to a couple of regions.

We are going to start with the menu. You will notice that as I begin to scale down, the menu is responsive, up until a point. There is not a lot of flex there. So when I hit the next break point, we get a little bit more flex within the menu. But notice the difference. The taglines for the menu go away. I don't need to display them at this level, simply because I am running out of screen real estate. The other thing is I have to be cognizant of the fact that for smaller devices such as tablets, and certainly smaller devices such as mobile devices, it's the touch that you need to worry about more than the cursor and the mouse.

So you will notice that the icons in the mobile app are actually larger than they are on the desktop and the tablet. And the reason for that is one of the things that you plan for when you're talking about links or clickable regions within a mobile touch screen is that typically the average size of a human finger that touches is about 44 pixels by 44 pixels. So you want to make sure those linked regions like that are going to be large enough to where people can hit them and touch them without bleeding over into another region, or making them too small to where it's frustrating for people to click.

Now, just below this, I want you to notice the banner area. Here on the mobile device there is no image, so again I'm saving a little bit of overhead there by not downloading an image on the mobile device. The descriptive text and the headline are still there. They are much smaller, and they take up a lot less screen real estate. On the tablet device, you'll notice that the banner image is used, but it's a smaller image. So again, less overhead, fits the space better. The heading is up here towards the navigation instead of down towards the bottom, and then the descriptive text is not overlaying the image anymore.

But on the desktop the descriptive text is over here, mimicking the right-hand column, and then the text is right over the top of it. And then finally, I really want to point out this region right here for you guys, which is the gallery preview region. You will notice on the desktop we have a fairly complex layout. We have the gallery name and the date side by side. We have a large image underneath that, and that large image is responsive in the fact that as you scale, you trim some of it off based upon the fluidity of the layout. And then we have the text underneath it. But as I go down to tablet, watch what happens to that region.

So it dramatically changes. We end up with that smaller gallery preview image that we talked about earlier. Again, it sort of is flexible in the same manner. But look what happens to the headline of the gallery and the date. They change their alignment with the image, and then of course the paragraph text changes as well. And on the smaller devices it goes back to a little bit more vertical layout. But again, instead of being side by side, we now stack these items as well and we use a smaller image. So those requirements for those responsive layouts for those different areas actually caused me to change how I would have normally structured that HTML.

And we talked about this in an earlier movie about how we have an empty sort of non-semantic div tag there for that image, and when I was planning the layout, I really fell in love with this design on the tablet, and it just forced me to say, there's just no other way for me to do this particular layout without throwing in an empty div tag. So that's sort of a concession that I had to make to wanting my layout to be that way. All right! So this lab is over, and you're probably tired of hearing me talk, but there is still plenty for you guys to explore.

Responsive design is a relatively new field, and there's so much more to it than what I can cover here. In fact, lynda.com will soon be adding several responsive-design titles to the Online Training Library, so be sure to keep your eye out for those.

Show transcript

This video is part of

Image for CSS: Page Layouts
CSS: Page Layouts

71 video lessons · 41419 viewers

James Williamson
Author

 
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

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
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.


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 "Already a member? Log in

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

Your file was successfully uploaded.

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.