How to make Simple Responsive Website Design Using CSS3 Media Query

By | December 27, 2013

Responsive Webpage is the webpage design, which will automatically resize based on screen resolution. Responsive webpage design will ensure the user interface. Responsive webpage design can be done in many ways like media query, bootstrap design, jquery, etc. Here is the tutorial for how to make simple responsive website design Using CSS3 media query.

 

 

HTML CODE (index.php)

[code type=html]

<html>
<head>
<link rel=”stylesheet” href=”style.css” type=”text/css”>
</head>

<body>
<div class=”header”>
<div class=”container”>
<div class=”logo”>
Logo
</div>
</div>
</div>
<!– end of header–>

<div class=”container”>
<div class=”content”>
Audience and Device Aware is an approach aimed at ensuring that a site is
optimised to deliver what a user wants and that works effectively on the
device being used to access the site. Unlike Responsive web design (RWD),
which crafts a site visually for a range of devices, ADA aims to reflect
the many different elements that enhance and impact on the performance and
usability of a site. The predominant application for the ADA approach is
for mobile and smaller screen devices. The principle truly sees the adoption
of a “mobile first” strategy and focuses on the performance of a site and
value that it delivers to a user and the business. Mobile first, unobtrusive
JavaScript, and progressive enhancement “Mobile first”, unobtrusive
JavaScript, and progressive enhancement (strategies for when a new
site design is being considered) are related concepts that predated RWD:
browsers of basic mobile phones
</div>
<!– end of content–>

<div class=”sidebar”>
<div class=”sidebar-title”>Sidebar</div>
<ul>
<li><a href=”#”>Sidebar 1</a></li>
<li><a href=”#”>Sidebar 2</a></li>
<li><a href=”#”>Sidebar 3</a></li>
<li><a href=”#”>Sidebar 4</a></li>
<li><a href=”#”>Sidebar 5</a></li>
</ul>
</div>
<!– end of sidebar–>

</div>
<!– end of container –>

</body>
</html>

[/code]

CSS CODE (style.css)

CSS, which are used inside the tag @media all and (max-width: 1000px) will be triggered when the window resolution is below 1000px

[code type=css]

.header
{
height: 150px;
background: #FC3;
margin: -8px -8px 8px -8px;
}
.logo
{
font-size: 36px;
color: #333;
padding: 20px;
}
.container
{
width: 1000px;
margin: 0 auto;
}
.content
{
width: 672px;
float: left;
margin: 0 5px 0 0;
padding: 4px;
background: #E9E9E9;
color: #363636;
}
.sidebar
{
width: 300px;
float: left;
background: #5FA882;
}
.sidebar-title
{
font-size: 28px;
text-transform: uppercase;
margin: 10px;
}

.sidebar ul
{
padding: 0;
margin: 0;
}
.sidebar li
{
display:block;
}
.sidebar li a
{
text-decoration: none;
display: block;
padding: 5px 3px;
margin: 10px;
background: #FAFAFA;
color: #000;
}

/* Media query for responsive*/
@media all and (max-width: 1000px) {
.container, .content
{
width: 100%;
}
.sidebar
{
width: 100%;
margin: 10px 0 0 0;
}
.sidebar-title
{
text-align:center;
}
}
[/code]

One thought on “How to make Simple Responsive Website Design Using CSS3 Media Query

Leave a Reply

Your email address will not be published. Required fields are marked *