23 Mei 2013

Smartphone revolution brings new features to the web development, it is time to change your website design into a responsive design instead of maintaining a separate mobile version . Responsive design will automatically adjust itself based on the screen size of the media devices. This post explain you how to use CSS 3 @media property and working with Internet Explorer using Modernizr.

Responsive Web Design using CSS3


Download Script
     Live Demo

Try live demo with different screen resolutions.

Step 1
Web layout divided into three horizontal parts are Hearder, Main and Footer. Here Header div divided into  two horizontal parts such as Logo and Nav and the same way Main div divided into Article and Sidebar.

HTML Code
<div id="header">
1 Header

<div id="logo">logo</div>
<div id="nav">links</div>
</div>

<div id="main">
2 Main

<div id="article">article</div>
<div id="sidebar">sidebar</div>
</div>

<div id="footer">
3 Footer
</div>

This is very useful for web development.

Wireframe
Responsive Web Design using CSS3

CSS
*{margin:0px;padding:0px}
#header
{
padding:20px;
overflow:auto;
}
#main
{
padding:10px;
}
#footer
{
padding:20px;
clear:both
}
#article,#sidebar
{
min-height:250px;margin-bottom:20px;overflow:auto
}

Step 2
Now working with an unorder list <ul> tag.
<div id="nav">
<ul>
<li>link</li>
<li>link</li>
<li>link</li>
....
....
</ul>
</div>

Responsive Web Design using CSS3

CSS
ul
{
list-style:none;
width:100%
}
li
{
padding:4px;
margin-bottom:5px;
background-color:#ffffcc;
text-align:center;
color:#00000
}

Step 3 - @media 768px
Working with screen media resolution minimum width at 768px

Wireframe @media 768px
Responsive Web Design using CSS3

CSS @media 768px
@media only screen and (min-width: 768px){

#article
{
float:left;
width:68%;
}
#sidebar
{
float:right;
width:30%;
}
#logo
{
float:left;
width:10%;
}
#nav
{
float:right;
width:80%;
}

}

Step 4 - @media 1140px
Working with screen media resolution minimum width at 1140px

Wireframe @media 1140px
Responsive Web Design using CSS3

CSS @media 1140px
@media only screen and (min-width: 1140px) {

#main
{
padding:20px 40px 20px 40px;
}

}

Step 5 - @media 480px
Working with Nav bar list media resolution minimum width at 480px. This is applicable for screen media resolution higher than 480px.
Responsive Web Design using CSS3

@media only screen and (min-width: 480px){

ul
{
float:left;
}
li
{
float:left;
width:16%;
padding:4px;
margin-right:8px
}

}

Modernizr
Modernizr is a JavaScript library that detects the availability of native implementations for next-generation Web Technologies. These technologies are new features that stem from the ongoing HTML5 and CSS3 specifications.
Responsive Web Design using CSS3

HTML Code
For implementing lower version browser like Internet Explorer 7 and 8, you just include modernizr.min.js after style sheet inside header tag. download link.
<!DOCTYPE html>
<!--[if lt IE 7]>
<html class="no-js lt-ie9 lt-ie8 lt-ie7">
<![endif]-->
<!--[if IE 7]>
<html class="no-js lt-ie9 lt-ie8">
<![endif]-->
<!--[if IE 8]>
<html class="no-js lt-ie9">
<![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
<title>Responsive Design with CSS</title>
//Meta tag for devices
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="style.css"> //Style Sheet
<script src="modernizr.min.js"></script>
</head>
<body>

<div id="header">

<div id="logo">Logo</div>
<div id="nav">

<ul>
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
<li>link</li>
</ul>

</div>

</div>

<div id="main">
<div id="article">Content Here</div>
<div id="sidebar">sidebar</div>
</div>

<div id="footer">
Footer
</div>

<body>
</html>

Now this code works fine with Internet Explorer lower version.

Note: Modernizer doesn't support inline CSS.

style.css
Final CSS

*{margin:0px;padding:0px}
#header
{
padding:20px;
overflow:auto;
}
#main
{
padding:10px;
}
#footer
{
padding:20px;
clear:both
}
#article,#sidebar
{
min-height:250px;margin-bottom:20px;overflow:auto
}

ul
{
list-style:none;
width:100%
}
li
{
padding:4px;
margin-bottom:5px;
background-color:#ffffcc;
text-align:center;
color:#00000
}

@media only screen and (min-width: 480px){

ul
{
float:left;
}
li
{
float:left;
width:16%;
padding:4px;
margin-right:8px
}

}

@media only screen and (min-width: 768px){

#article
{
float:left;
width:68%;
}
#sidebar
{
float:right;
width:30%;
}
#logo
{
float:left;
width:10%;
}
#nav
{
float:right;
width:80%;
}

}

@media only screen and (min-width: 1140px) {

#main
{
padding:20px 40px 20px 40px;
}

}

Note: Modernizer doesn't support inline CSS.
Credit

17 Mei 2013


In this tutorial im gonna explain how to add Bouncing  with jQuery.It  have nice hover effect. Every menu are
different  with colors. Im   using   jQuery and  HTML,  Just check out demo.Its easy to add to blogger. get my all menu bar here

1. Log in to blogger account and Click drop down.
blog-post-option
2. Now select "Template" Like Below.

Select-template

3. Now you can see Live on blog, Click EDIT HTML Button"

4. Now click Proceed button.
   
5. Find this tag by using Ctrl+F    </head>

6. Paste below code Before </head> tag

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js?ver=3.2.1' type='text/javascript'/>
<script src='http://bloggertrixcode.googlecode.com/files/jquery.easing.1.3.js' type='text/javascript'/>
<script src='http://bloggertrixcode.googlecode.com/files/animated-menu.js' type='text/javascript'/>

7. Go to blogger and click Layout

8. Click Add Gadget and select 'HTML/Javascript

9. Paste below code.

ul{
margin:0;
padding:0;
}
a:link {
color: #F8F8F8;
text-decoration: none;
font-weight: bold;}
li{
width:100px;
height:50px;
float:left;
color:#191919;
text-align:center;
overflow:hidden;
}
a{
color:#FFFFFF;
font-size:15px;
text-decoration:none;
}
p{
padding:0px 5px;
}
.subtext{
padding-top:15px;
}
/*Menu Color Classes*/
.green{background:#6AA63B url('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8iSS3OnTCM4Gz0rAlw23FZCiEFmTAlj5mZbSZRDr8XcPnaoHVHph32_WxEoAHzP_ic08NKyFAWhAc_KtUpQHWiRoDmqblNcAmpceWqWuK49hX6o4ZQmsczi3DI62JNp6Ie_MO0iSufCg/s1600/btrix_green-item-bg.jpg') top left no-repeat;}
.yellow{background:#FBC700 url('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGnW8qr-y8iM7C65fLB_VA2hrG7GWhM2JPCNhHqTu7d6CRA6OzJjPrSaf6pRuhl9wbMpB_PGgvKpAErm7JZAjjzkYMiB987iqrCP62rr_epIKobOut2swBachnRH8dvcXBZx7IrIxZvxM/s1600/btrix_purple-item-bg.jpg') top left no-repeat;}
.red{background:#D52100 url('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsVxOi7conZKoYjDOInIsP1TVALurVC-t9ThjwMML_TNvZNexv0yRRxrmd-PkynSda6q101-dtWQ8GQP2d1yuq-GnwT2tk2sF2QkV6SJIu7O-NxsCOw8ivlGlLTEa4QcL5SNrm0oRYDDc/s1600/btrix_red-item-bg.jpg') top left no-repeat;}
.purple{background:#5122B4 url('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVu94XJK_PlSf7xbyQiv1c2FdiA7LNQ56adgHWjS-CW1IJ1FTCIiIcB5faWXXSqjvesIHw1QjwODWfzhWCvNxiYG1uTJcgNuymbnV2_-_NBivScZdUphuJ5aEqXyi0T4Uv-JvLX-8H0tw/s1600/btrix_blue-item-bg.jpg') top left no-repeat;}
.blue{background:#0292C0 url('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgActvEAqDMBotAYi3-Z0JzIerLZ23oO8Ly4k5NX_UqnGafKZbo3MV6Jtbo1MYjpjNplv82XIG7wFY6ZETLs-0WrxdkpOIfv8QxhbXGmsy7l6ShG8gWLZSlie7RFAveEuPObJx3Ii6dh-0/s1600/btrix_yellow-item-bg.jpg') top left no-repeat;}
</style>
<ul>
<li style="overflow: hidden; height: 50px; display: block;" class="green">
<p><a href="#">Home</a></p>
<p class="subtext">The front page</p>
</li>
<li style="overflow: hidden; height: 48px; display: block;" class="yellow">
<p><a href="#">About</a></p>
<p class="subtext">More info</p>
</li>
<li style="overflow: hidden; height: 50px; display: block;" class="red">
<p><a href="#">Contact</a></p>
<p class="subtext">Get in touch</p>
</li>
<li style="overflow: hidden; height: 50px; display: block;" class="blue">
<p><a href="#">Submit</a></p>
<p class="subtext">Send us your stuff!</p>
</li>
<li style="overflow: hidden; height: 50px; display: block;" class="purple">
<p><a href="#">Terms</a></p>
<p class="subtext">Legal things</p>
</li>
</ul>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-6444047-1");
pageTracker._trackPageview();
} catch(err) {}</script>
Replace # with your links.

10. Now save your HTML/Javascript'.

Mengenai Saya

Postingan Populer