Responsive web design is no doubt a big thing now. If you still not familiar with responsive design, check out the list of responsive sites that I recently posted. To newbies, responsive design might sound a bit complicated, but it is actually simpler than you think. To help you quickly get started with responsive design, I've put together a quick tutorial. I promise you can learn about the basic logic of responsive design and media queries in 3 steps (assuming you have the basic CSS knowledge).
Step 1. Meta Tag (view demo)
Most mobile browsers scale HTML pages to a wide viewport width so it fits on the screen. You can use the viewport meta tag to reset this. The viewport tag below tells the browser to use the device width as the viewport width and disable the initial scale. Include this meta tag in the <head>.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Internet Explorer 8 or older doesn't support media query. You can use media-queries.js or respond.js to add media query support in IE.
<!--[if lt IE 9]>
<script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script>
<![endif]-->
Step 2. HTML Structure
In this example, I have a basic page layout with a header, content container, sidebar, and a footer. The header has a fixed height 180px, content container is 600px wide and sidebar is 300px wide.
Step 3. Media Queries
CSS3 media query is the trick for responsive design. It is like writing if conditions to tell the browser how to render the page for specified viewport width.
The following set of rules will be in effect if the viewport width is 980px or less. Basically, I set all the container width from pixel value to percentage value so the containers will become fluid.
Then for viewport 700px or less, specify the #content and #sidebar to auto width and remove the float so they will display as full width.
For 480px or less (mobile screen), reset the #header height to auto, change the h1 font size to 24px and hide the #sidebar.
You can write as many media query as you like. I've only shown 3 media queries in my demo. The purpose of the media queries is to apply different CSS rules to achieve different layouts for specified viewport width. The media queries can be in the same stylesheet or in a separate file.
Conclusion
This tutorial is intended to show you the basics of responsive design. If you want more in-depth tutorial, check out my previous tutorial: Responsive Design With Media Queries.
Hi!
I have a question… If my page is visited by some resolution, could be 1280×1024, the browser loads the content made for the other screen resoutions (1024×720 – 144×900 -1366×768 etc ?? the thing is that my website loads different size images depending of the screen resolution, and would be bad thing if loads everything… thank you
Thx that after some Google I found this. Just what I was looking for. Thx a lot
The functions you showed up in your blog clarifies better designing, with all this we all need the designing more keen.
great stuff guys …. Just tweeted about this, Thank you
Great information, thank you!
Thanx a lot!
After a long time I got some good stuff to read, especially that ‘Media Queries’ part that clearly shows the flow of the design.
Thx a lot!
This is a great introduction tutorial.
Responsive Design is definitely becoming the standard in web design. More and more people want their websites to be easily viewable on a variety of devices including computers, tablets and mobile devices. Traditional websites with fixed widths are limited in their capabilities, but responsive websites can resize and adjust based on the size of the users screen. Responsive web design isn’t necessarily new thinking, but it’s definitely becoming more popular in modern web design.
If you’re interested in checking out responsive website examples, head on over to http://www.gottaloveresponsivedesign.com. It has a lot of great examples of websites using responsive design.
Your responsive theme works really well. How did you hide just the ads in the sidebar? Is it by using two sidebars one below the other and hiding the one with the ads on it?
Thanks for the simple tut! I’m curious how you would handle navigation/menu wrapping?
Very good tut. Thanks alot.
Very nice tutorial. It helped me to make a base to do responsive design.
Thanks !!
This is great thanks!! :)
This is a great introduction tutorial. Thx that after some Google I found this.
Can you do a tutorial on how to hide the header and footer from a page in a responsive theme? I want to keep it fluid still I know how to create a standard page where I can do that but not with responsive themes.
Using responsive scale designs on my new business site – I’m using the Skeleton CSS grid as a base, which saved me a lot of time! And the framework code is clean & easy to understand, and so far it looks great on iPads & iPhones, as well as Blackberries.
Sweet post! Short and clear to understand the basic concept of responsive design. Thank you.
Using responsive scale designs on my new business site – I’m using the Skeleton CSS grid as a base, which saved me a lot of time! And the framework code is clean & easy to understand, and so far it looks great on iPads & iPhones, as well as Blackberries. Desktop Wallpaper, HD Wallpaper, Wallpaper Background
Desktop Wallpaper
This really exact what the words says Web Designer wall. Appreciated
I am a starter and this is surely going to be of great use to me. Thank you for the worthy sharing and waiting for such other articles!
Thanks for the simple tut! I’m curious how you would handle navigation/menu wrapping Desktop Wallpaper, HD Wallpaper, Wallpaper Background
Desktop Wallpaper