Wall Script
Follow Me:
Sunday, December 30, 2012

Responsive Web Design for Menu, Image and Advertisements

This post is the continuation of my previous Responsive Web Design using CSS3. I had explained how to design a basic responsive web page using CSS3 and Modernizr for lower version browsers. In this post we want to explain how to design responsive collapsed navigation menu, images and advertisements grids for different media devices.

Responsive Web Design using CSS3

Download Script
     Live Demo

Try live demo with different screen resolutions.

Arun Kumar Sekar
Arun Kumar Sekar

Engineer, Plugin Expert
Chennai, INDIA

Image responsive design is very simple, just give width and height 100%

<div class="responsiveImage">
<img src="image.jpg" />

CSS Code
.responsiveImage { width: 100%;clear: both;}
.responsiveImage img{ max-width: 100%; max-height: 100%; }

Collapsing navigation menu for mobile devices to reduce screen responsive.

<div class="menubar">
<div class="responsive-menu">
Menu <a href="javascript:void(0);"><span class="menuicon"></span></a>

<ul class="menu">
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>

<div style="clear:both;"></div>

CSS Code @media 768px +
Here .menu > li is float:left
a { text-decoration: none; }
.menubar { width:100%; height:39px; background-color: #006699; }
.menu { float: left; position: relative; padding: 10px; }
.menubar .menu > li { float: left; line-height: 20px; }
.menu > li > a { color: #ffffff; font-size: 15px; padding:10px 15px 10px; }
.menu > li > a:hover, .menu > li > a:active { background-color:#4682b4; border-radius:4px; }
.responsive-menu { display: none; color: #ffffff; font-weight: bold; padding: 5px; border-bottom: 2px solid #ffffff;width:100%; }

CSS Code @media 767px -
Here .menu > li is width:100%
@media (max-width: 767px) {
.menubar{clear:left; height:auto !important; display: table; }
.menu{ float: none; width:100%; padding:0px !important; display: none; }
.menubar .menu > li { width:100%; border-bottom: 1px solid #dedede; cursor: pointer; padding-top: 5px; padding-bottom: 5px; }
.menu > li:hover, .menu > li:active { background-color:#4682b4;}
.responsive-menu { display: inline-block !important; }

CSS Code for menu dropdown arrow.
/* Down Arrow Icon */
.menuicon {
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-top: 10px solid #ffffff;
position: absolute;
right: 8px;

Contains javascipt code. $(".menuicon").click(function(){} - menuicon is the class name of the arrow. Using slideToggle $(".menu").slideToggle(); for drop down this list.
<script src="jquery.min.js"></script>
<script type="text/javascript">

// Window resizing function
if($(this).width() < 767)


$(window).resize(function() is understand the screen resolution, based on width it will show and hide .menu part.

Advertisement Blocks

I have created three horizontal DIVs are .ad_big 728px, .ad_medium 468px and .ad_small 300px.
<div class="ad_big">728px Ad</div>
<div class="ad_medium">467px Ad</div>
<div class="ad_small">300px Ad</div>

CSS Code
Based on media resolution system will show advertisement blocks.
.ad_big,.ad_medium,.ad_small{ padding:5px;margin:5px; }
.ad_medium,.ad_small { display:none; }

/* Ads devices */
@media (min-width: 478px) and (max-width: 738px) {
display: block !important;
.ad_big,.ad_small {
display: none;

@media (min-width: 325px) and (max-width: 477px) {
.ad_small {
display:block !important;
.ad_big,.ad_medium {
display: none !important;

@media (min-width: 0px) and (max-width: 324px) {
.ad_small {
display:block !important;
.ad_big,.ad_medium {
display: none !important;

Pajjek Man said...


Sujay Sreedhar said...

thanks :D that really helped :)

hima javvadhi said...

:) <3 Good explanation

Anonymous said...

Google Ads lligal like that

morrelinko said...

Nice One.

Brebleme said...

Thank you
it's really very usefull

Pankaj Patel said...

The Responsiveness of Advertisement section will be very helpful for me!

Anonymous said...

ie8 not supporting media sizes

Manish said...

Very nice post Arun. Responsive web designs are more useful than others.

Mohit said...

Perfect one what i always wanted to get!! Thanks a lot.

bastr3 said...

nice move :)

john said...

yups, nice tutorial :D

Aslan Simin said...

awesome goog job buddy

Alexander said...

Wow! Nice tutorial and Happy New Year 2013!

Tejas P Mehta said...

Hello Arun,

I have 2 level of Menu. What should i do to mange that ? Your example is for 1st level only. It will be helpful if you update this with 2-3 level menu.

Thank you

Anonymous said...


John said...

Why your site 9lessons is not yet responsive..

Danny said...

It's not working (I'm using the demo via my iPhone) but thanks for this post :)

aditia said...

great love the responsive menu

Anonymous said...

love it !

Alexander said...

Nice tutorial;)

Pond Leaks said...

I have read your last post and read this also. keep sharing.

Atul said...

You always did an awesome work!!

Vivek Kumar said...


BlueHeart said...


konteynerler said...

I was looking forward that. Thanks for it.

Anonymous said...

I am looking forward for that and really a great thing you have explained here.

Atul Kumar Pandey said...

Nice tutorial. I would like to use this thing on my private blog also. Thanks for sharing this.

Techbymak said...

Nice Man,
I'm trying to implement this code on the blogger template to create a responsive Blogger template. Thank you Shrinivas.

webspiderdesigns said...

thank you arun

Norant said...

use display:inline-block and vertical-align:middle or top instead of float:left or right,
learned some responsive design here, thanks

Saksham Goyal said...

Great man it helped me a lot...really good work

vipul said...

I was learning twitter bootstrap for creating responsive page. Your tutorial is also very helpful.

Unknown said...

is it poosibe to added a search bar to the menu, if yes how?

Atul Kumar Pandey said...

I used this in my blog and enjoyed over 1 month a responsive design. Thanks mate for a nice tutorial.

Post a Comment