Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
The many ways visitors access web sites, via mobile devices, tablets, and desktops, now requires sites to incorporate responsive design elements that adapt to different screen sizes and browsers. In this course, Morten Rand-Hendriksen demonstrates design strategies, best practices, and actual code examples for creating a responsive web site. The course covers layout, navigation, responsive video embedding, and content sliders. The final chapter shows how to create an index page with jQuery Masonry, a jQuery plugin that helps you create dynamic grid layouts.
Once you have a clear idea of how your content will look on different screen sizes, you need to make sure your markup allows for this type of realignment. The one thing to keep in mind is that while the presentational aspects of your site may change as your responsive theme responds to different screen sizes and other scenarios, the markup, that is, the code behind the scenes, stays the same. That means your markup needs to accommodate all your different layouts simultaneously without becoming unnecessarily cluttered in the process.
To make sure I know how I need to divide up my content, I like to draw lines in my designs so I can see what different sections I need to section off and how they relate to each other, and then I can match that between my full-size layout and my phone layout and see how these elements move in relation to each other. Let's, for example, take a look at the header. If I draw a box around the entire header, you'll see that we actually have three elements here. The reason why I know we have three elements is because if I look at the full-size version of the site versus the mobile-size version of the site I see the margins here are quite different.
So, what I mean to do is make sure I'm able to address those margin issues on both the site title and the menu. So, I am going to box the title and menu into a separate box, and then I am going to separate each one of them. I'll separate this one and I'll separate this one out. Now that I've done this on my wide layout, I can match these boxes on my narrow layout. So, I'll go in here and find the same area, and since I know that these boxes span around both the title and the menu, I have to span the box across the whole thing, and then I have to separate out the content.
So I'll separate out all the content first, and then I'll draw a box around the title and another box around my menu. So, based on this layout, I now know that I need to have a container and then another container within that container and then a container around my header and a container around my menu so that I can float them differently, because now I can see that the title needs to float to the left and the menu has to either float to the right on the full layout or float to the bottom on the phone layout.
Likewise, I can take a look at my main content. I know that all this content is contained within one box, but then I have to separate these further. The header content is handled separately from the main content, meaning that I have to treat this entire section as one unit and then this entire section as another unit. So, I'll do the same thing in my mobile layout again. I'll draw a box around all the content, and then I can separate out the individual pieces.
So, I have one section here for the header content and the meta element, and then I have another section here for the general body of the post. Looking at the two of them side by side, I now see that on the mobile side, everything is fine; I just have one set of content on top of the next. But in the wide layout, I now need to float the header content to the left and float the rest of the content to the right.
But this isn't as easy as it looks, because if I float it using the general float behavior, I'll end up with this content spanning in underneath. So I have to use some sort of trick to shift everything into place the way I want it to, and we'll address that later in the course. But that just proves the point I'm trying to make. Before you start writing your markup, you need to know which pieces of content relate to each other and how they relate to the other pieces on the page. That way you can put containers around pieces that belong together and these pieces then become easier to handle, because you can place them next to one another or on top of one another or hide one and show the other one depending on what you want to do in your layout.
By drawing out your main sections in your design and making it clear to yourself how they relate to one another, you'll be able to build markup that is ready to be responsive.
There are currently no FAQs about WordPress: Building Responsive Themes.
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.