Pages - Menu

Monday, 17 February 2014

Build a basic responsive site with CSS


What is Responsive Design View?

Responsive designs adapt to different screen sizes to provide a presentation that is suitable for different kinds of devices, such as mobile phones or tablets. The Responsive Design View makes it easy to see how your website or web app will look on different screen sizes.

How to make a basic responsive site with CSS

Step1:- Create a demo.html file and put this html in it.


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title> Demo | Responsive Web</title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0" />
<link href="main.css" type="text/css" rel="stylesheet">
<script type='text/javascript' src='respond.min.js'></script>
</head>
<body>

<div id="wrapper">

<header>

<nav id="skipTo">
<ul>
<li>
<a href="#main" title="Skip to Main Content">Skip to Main Content</a>
</li>
</ul>
</nav>

<h1>Demo</h1>

<nav>
<ul>
<li><a href="#" title="Home">Home</a></li>
<li><a href="#" title="About">About</a></li>
<li><a href="#" title="Work">Work</a></li>
<li><a href="#" title="Contact">Contact</a></li>
</ul>
</nav>

<div id="banner">
<img src="responsive_design.jpg" alt="banner" />
</div>

</header>

<section id="main">
<h1>Main section</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</section>

<aside>
<h1>Sub-section</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</aside>

</div>

</body>
</html>

Step 2:- Create a file main.css and put this CSS code in it


/* Reset
------------------------------------------------------------ */
* { margin: 0; padding: 0; }
html { overflow-y: scroll;}
body { background:#ffffff; font-size: 13px; color: #666666; font-family: Arial, helvetica, sans-serif;}
ol, ul { list-style: none; margin: 0;}
ul li { margin: 0; padding: 0;}
h1 { margin-bottom: 10px; color: #111111;}
a, img { outline: none; border:none; color: #000; font-weight: bold; text-transform: uppercase;}
p { margin: 0 0 10px; line-height: 1.4em; font-size: 1.2em;}
img { display: block; margin-bottom: 10px;}
aside { font-style: italic; font-size: 0.9em;}
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}

/* Structure */
#wrapper {
width: 96%;
max-width: 920px;
margin: auto;
padding: 2%;
}

#main {
width: 60%;
margin-right: 5%;
float: left;
}

aside {
width: 35%;
float: right;
}

/* Logo H1 */
header h1 {
height: 70px;
width: 160px;
float: left;
display: block;
background: url(../images/demo.gif) 0 0 no-repeat;
text-indent: -9999px;
}

/* Nav */
header nav {
float: right;
margin-top: 40px;
}

header nav li {
display: inline;
margin-left: 15px;
}

#skipTo {
display: none;
}
#skipTo li {
background: #b1fffc;
}

/* Banner */
#banner {
float: left;
margin-bottom: 15px;
width: 100%;
}

#banner img {
width: 100%;
}


/* Media Queries */
@media screen and (max-width: 480px) {

#skipTo {
display: block;
}

header nav, #main, aside {
float: left;
clear: left;
margin: 0 0 10px;
width: 100%;
}
header nav li {
margin: 0;
background: #efefef;
display: block;
margin-bottom: 3px;
}
header nav a {
display: block;
padding: 10px;
text-align: center;
}

}

Step 3:- Download the javascript file



The Result will look like this 


Note:Don't forget to put all three files in a same folder 

Download the full source code here

Hope You enjoy this tutorial..!

3 comments:

  1. http://funnylad.com/FunnyPictures.html

    ReplyDelete
  2. The Most funny Quotes you can find here :
    http://www.funnylad.com/FunnyQuotes.html#sthash.5eMajbQq.dpbs

    ReplyDelete