Responsive web design is the approach that suggests in which design and development should respond user behavior and environment based on the size of the browser screen, platform and orientation.
Here I have explained some steps for creating your blog responsive.
Step1: Add meta tags for responsiveness
Add the following meta tags on your blogger template using the following steps.
- Go to blogger dashboard and click on template
- Backup your template for the risk while editing template codes.
- Paste the following codes between and <head> and </head> tags.
- Save your blogger template.
Add the following codes to size the contents of blog equal to the device width.
<meta name="viewport" content="width=device-width/">
Add the following codes to size the contents of blog equal to the device width and device height.
<meta name="viewport" content="width=device-width, height=device-height/">
Add the following codes to size the contents of blog equal to the device width and initial zoom size.
<meta name="viewport" content="width=device-width, initial-scale=2"/>
Add the following codes to size the contents of blog equal to the device width, initial zoom size and maximum zoom size.
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1/">
Instead or writing meta tags, you can do the same with the following codes in CSS.
@-moz-viewport {
width: device-width;
}
@-moz-viewport {
width: device-width;
height:device-height;
}
@-moz-viewport {
width: device-width;
initial-scale:2;
}
@-moz-viewport {
width: device-width;
initial-scale:1;
maximum-scale:1;
}
This works only for Mozilla browser, for other browsers you can use -o-, -webkit- and -ms- as prefixed properties.
Step2:Add media queries for each screen size
Add the following media queries between <![CDATA[*/ and ]]> tags.
@media screen and (max-width:320px){
/*For Small Screen Moblies*/
}
@media screen and (max-width:480px){
/*For Smart Phones and iPhones*/
}
@media screen and (max-width:768px){
/*For Small Tables*/
}
@media screen and (max-width:1024px){
/*For Notebooks*/
}
You can add more media queries according to your need for different screen sizes and orientations and can also use min-width: to specify minimum width of screen.
To specify the screen orientations landscape or portrait use
@media screen and (max-width:480px) and (orientation:landscape) { }
Step3: Write custom CSS code for media queries
Now, you have to add custom CSS codes for each media queries. The default CSS properties written are replaced by the properties written within these media queries. Here is the sample CSS code written for mobile devices, you can add these codes for media screen with max-width 320 and 480 px.
#wrapper {
width:85%;
}
#content{
width:100%;
}
#sidebar-left{
width:100%;
clear:both;
}
#sidebar-right{
width: 100%;
clear:both;
}
Alternate method for adding CSS code with media queries
<link rel="stylesheet" media="screen" href="screen.css"/>
You have to give the full path for "screen.css", where the file is placed.
You can also link different style sheet files for different screen sizes as below.
<link rel="stylesheet" media="screen and (max-width:1280px)" href="large.css"/>
<link rel="stylesheet" media="screen and (max-width:480px)" href="small.css"/>
Related Posts:
- How to Create Simple Blogger Template Easily?
- How To Make Simple CSS Stylesheet for a Website ?
- How To Create Simple Menu Using CSS ?
- How to validate required field in a form using javascript
- How to Display Date Format in JavaScript?
- How to Create a Digital Clock in JavaScript?
- What are the Different Ways to Redirect Page in JavaScript?
- How to Detect Visitor's Browser Using JavaScript?
- Image Slideshow with Navigation Buttons Using Javascript
- How to Create Simple JavaScript Fade Effect Animation?
- Simple JavaScript Fade Effect Animation Using Jquery
إرسال تعليق
Click to see the code!
To insert emoticon you must added at least one space before the code.