Category : Javascript | Author : Chtiwi Malek | First posted : 4/4/2012 | Updated : 2/17/2013
Tags : footer, css, javascript, ajax, bottom, html, website, position, layout, jquery, updatepanel, cross browser
The best Sticky Footer

The best Sticky Footer

This document describes how to make a footer that sticks to the bottom of the page even if the page content is less than the browser window height, so you don’t have a footer appearing in the middle of the browser window. This solution is cross browser and you dont need a fixed height for the footer.

I’ve tried and come across many Sticky Footer on the web, but all have issues:

Pure CSS Sticky Footer: will not render correctly on all browsers, and you will have to add fixes or extra HTML markup for some browsers or old ones.
Pure JavaScript Sticky Footer that relies on an empty push div has rendering issues when resizing the window quickly.

So I decided to write my own code :
function positionFooter() { var mFoo = $("#myfooter"); if ((($(document.body).height() + mFoo.outerHeight()) < $(window).height() && mFoo.css("position") == "fixed") || ($(document.body).height() < $(window).height() && mFoo.css("position") != "fixed")) { mFoo.css({ position: "fixed", bottom: "0px" }); } else { mFoo.css({ position: "static" }); } } $(document).ready(function () { positionFooter(); $(window).scroll(positionFooter); $(window).resize(positionFooter); $(window).load(positionFooter); });
This code needs jQuery and will position the element footer with id “myfooter” at the bottom if the page length is shorter than the browser window length and will place it in the normal flow if the page is longer or equal to the browser window length.

.NET Ajax UpdatePanel & the Sticky Footer

If you're a .NET developer and using the ScriptManager and Ajax UpdatePanels you'll need a call to the javascript fonction positionFooter() after an ajax partial postback, because the page length will change when the updatepanel updates it’s content. So just add this code to the page or master page where your Update panel is defined, Just change "up1" with your UpdatePanel ID :
if (IsPostBack)
{
  ScriptManager.RegisterStartupScript(up1, up1.GetType(), "ppf", "positionFooter();", true);
}
Have fun and don't hesitate to ask me any questions or send me your thoughts.
About the author :
Malek Chtiwi is the man behind Codicode.com
34 years old full stack developer.
Loves technology; but also likes design, photography and composing music.
Comments & Opinions :
Jquery Sticky Footer
Thank you so much! I have been struggling for hours with various css versions and your jquery version worked 100% first time!!!
- by Munro on 4/20/2012
Jquery Sticky Footer
Thanks for the code! it works perfect for me in a responsive website :D
- by Jorge on 4/20/2012
thanks
it works!
thanks for sharing
- by Nurul Amin Russel on 5/3/2012
You are awesome thank you!
I've been struggling with this for a long time and this one worked for me. Thanks
- by Ubaid Seth on 5/11/2012
Example?
Could you post an example code/page of this working? I believe it works, but I'm not exactly sure how I'm supposed to enter all of this in there.
- by Kpppp on 5/31/2012
I would also like an example :)
Is it hard to implement this into my HTML? I've never used jquery before so I would really appreciate it if someone would show me how it's done.
- by Johan on 6/2/2012
Thank you!
I've tried all the other versions and your worked perfectly! Excellent method!
- by Cristian on 6/24/2012
Excellent Example
Wowwwwww... this is really great. and very simple example. worked really awesome to me.

thanks a lot for this tut i have been struggling a lot for this simple code since long time.
- by Mahendra on 6/26/2012
Padding in footer
If you are using padding in your footer, you can better change: mFoo.height() to mFoo.outerHeight()
- by Ben on 8/27/2012
Few issues
I have tried to make this work with various layouts but FIXED position seems to cause problems with the footer width, and even if a fixed width is set for the footer it causes problems with centering if the screen size is small than the fixed width. I would like to see a working demo that addresses these issues.
- by John on 9/13/2012
Thank you!
This is the best footer ever! I have tried so many different solutions and none of them were ever really satisfactory. This is exactly what I needed, and so easy to implement. Thank you so much!
- by Rachael on 11/1/2012
Awesome!
Thank you very much
- by Fluc on 11/29/2012
Changed something to be perfect, Thanks.
Hello, this is the best script I could find.
It works in IE 7, 8, 9, 10, and al other modern browsers and also on the iPad and iPhone with iOS 6.0.1.
I only changed all "fixed" values to "absolute" because when the footer isn't higher than the viewport height and you make the browser window very small in width it isn't possible to scroll to the right to see al the content of the footer.

Thanks Malek.
- by Jeroen on 11/29/2012
Saved my ass
This problem was killing me until your glorious code saved my ass. One day I hope to be as rad as you. Honest.
- by Onetriphudson on 11/30/2012
Seriously! Great coding!
I have been looking for a long time for a solid jquery stickyfooter.. You nailed it!
- by Christoph on 2/1/2013
fixed and widht
Great script!
Same problem as John. Width problem when position:fixed.
I've added width:auto whit position:static and width:100% whit position:fixed.

For me work on bootstrap template.

I have to change $ whit JQuery.

bye Marco.
- by marco on 3/14/2013
I love you
YES I DO !
- by kadir on 7/28/2013
Thank You!!
No matter what new script I've tested, time and again, this is by far the most reliable script I've ever found. Thank you!
- by Julie on 8/26/2013
Thank you very much!
I tried around 5 other solutions before finding this one. It took me about 5 hours to get a sticky footer to work on my responsive site, wish I would have seen this sooner. Great solution!
- by Paul on 9/8/2013
The best solution I could find
Thanks Malek for a really easy to implement solution! If you're already using jQuery this seems the best solution out there to realiably work on everything.
- by Matt on 11/20/2013
could you please share an example of this code.
Is it hard to implement this into my HTML? I've never used jquery before so I would really appreciate it if someone would show me how it's done or share a example; which to use this code.

Thanks.
- by Lokesh on 11/22/2014
can somebody tell me how to use it
can somebody tell me how to use it
- by Hans on 12/2/2014
small issue
So I have a small issue. I am using this script and its working beautifully. Only issue is, when I have a piece of hidden div's that will be shown on click event, when visable, depending on browser size, the content is now "under" the footer "layer" so it looks like its covered by the footer. If you resize the browser it corrects itself immeidately. How can I get it to detect that if there are no scroll bars on page load, and the content is under the footer, to adjust the footer and footer margin to show the hidden content?
- by Chris on 1/21/2016
Thanks a lot
was struggling with this sticky footer for almost 5 days ..finally i found this link and its superb and cool....rock on
- by Cr Aravind on 2/29/2016
Sticky Footer Responsive Web Design
HTML-Markup:

1.  <header class="page-row">
2.  <h1>Site Title</h1>
3.  </header>
4.  <main class="page-row page-row-expanded">
5.  <p>Page content goes here.</p>
6.  </main>
7.  <footer class="page-row">
8.  <p>Copyright, Lorem ipsum dolor sit amet, consetetur sadipscing elitr, [...] Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
9.  </footer>

CSS-Code:

1.    html,
2.    body { height: 100%; }
3.    body {
4.    display: table;
5.    margin:0;
6.    padding:0;
7.    width: 100%;
8.    }
9.   .page-row {
10.  display: table-row;
11.   }
12.  .page-row-expanded { height: 100%; }
 
- by SCHMIDT on 4/2/2016
Sticky Footer Responsive Web Design
HTML-Markup:

1.  <header class="page-row">
2.  <h1>Site Title</h1>
3.  </header>
4.  <main class="page-row page-row-expanded">
5.  <p>Page content goes here.</p>
6.  </main>
7.  <footer class="page-row">
8.  <p>Copyright, Lorem ipsum dolor sit amet, consetetur sadipscing elitr, [...] Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
9.  </footer>

CSS-Code:

1.    html,
2.    body { height: 100%; }
3.    body {
4.    display: table;
5.    margin:0;
6.    padding:0;
7.    width: 100%;
8.    }
9.   .page-row {
10.  display: table-row;
11.   }
12.  .page-row-expanded { height: 100%; }
 
- by SCHMIDT on 4/2/2016
Sticky Footer Responsive Web Design
HTML-Markup:

1.  <header class="page-row">
2.  <h1>Site Title</h1>
3.  </header>
4.  <main class="page-row page-row-expanded">
5.  <p>Page content goes here.</p>
6.  </main>
7.  <footer class="page-row">
8.  <p>Copyright, Lorem ipsum dolor sit amet, consetetur sadipscing elitr, [...] Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
9.  </footer>

CSS-Code:

1.    html,
2.    body { height: 100%; }
3.    body {
4.    display: table;
5.    margin:0;
6.    padding:0;
7.    width: 100%;
8.    }
9.   .page-row {
10.  display: table-row;
11.   }
12.  .page-row-expanded { height: 100%; }
 
- by SCHMIDT on 4/2/2016
Awesome!
Thanks for this!  Been struggling with this!  Works like a gem.
- by Fred Lunau on 4/6/2016
yueqin

cheap jordan shoes

 

swarovski sale

 

bercrombie

 

yeezy shoes

 

polo ralph lauren outlet online

 

louboutin outlet

 

louis vuitton

 

longchamp pliage

 

coach handbags outlet

 

coach outlet store online

 

adidas running shoes

 

yeezy boost

 

fitflops

 

coach factory outlet store

 

true religion jeans

 

coach outlet canada

 

kate spade handbags

 

air max outlet

 

michael kors bags

 

michael kors

 

jimmy choo shoes

 

ed hardy uk

 

air jordans

 

coach outlet store online clearance

 

christian louboutin outlet

 

jordan retro

 

christian louboutin outlet

 

swarovski uk

 

birkenstock outlet

 

burberry sale

 

michael kors outlet clearance

 

tory burch outlet online

 

michael kors purses

 

michael kors outlet online

 

louis vuitton outlet online

 

marc jacobs

 

marc jacobs outlet

 

adidas sneakers

 

coach factory outlet

 

jordan femmes pas cher

 

kate spade outlet store

 

discount oakley sunglasses

 

michael kors outlet store

 

ralph lauren sale

 

jerseys cheap

 

polo ralph lauren outlet online

 

pandora charms sale

 

michael kors outlet clearance

 

beats wireless headphones

 

kd 8 shoes

 

birkenstocks

 

coach outlet online

 

coach factory outlet online

 

nike sneakers

 

coach factory outlet

 

michael kors outlet clearance

 

tommy hilfiger windbreaker

 

christian louboutin

 

cheap rolex watches

 

fitflops

 

sac louis vuitton

 

kate spade

 

kate spade outlet online

 

toms outlet

 

louis vuitton purses

 

timberland boots outle

 

nike uk

 

coach outlet online

 

fitflop shoes

 

gucci

 

cheap oakley sunglasses

 

coach factory outlet

 

air max 90

 

coach outlet online

 

michael kors handbags clearance

 

ralph lauren uk

 

polo ralph lauren outlet online

 

celine outlet online

 

nike outlet store

 

kate spade outlet

 

discount oakley sunglasses

 

michael kors

 

moncler jackets

 

rolex replica watches

 

rangers jerseys

 

birkin handbags

 

coach outlet online

 

louis vuitton factory outlet

 

tory burch sale

 

ralph lauren outlet online

 

birkenstock outlet

 

christian louboutin outlet

 

true religion jeans outlet

 

michael kors

 

cheap oakley sunglasses

 

yeezy boost 350

 

longchamp handbags

 

cheap oakley sunglasses

 

red bottom shoes for women

 

michael kors outlet clearance

 

coach factory outlet online

 

cardinals jerseys

 

ray bans

 

ghd straighteners sale

 

fendi bags

 

nike outlet

 

coach outlet store

 

adidas outlet store

 

cheap oakley sunglasses

 

yeezy boost 350 v2

 

adidas sneakers

 

red bottom

 

tods shoes

 

mulberry uk

 

pandora bracelet

 

thunder jerseys

 

sac longchamp

 

cheap nfl jerseys

 

christian louboutin uk

 

ralph lauren

 

true religion

 

tommy hilfiger outlet

 

ralph lauren outlet online

 

oakley sunglasses outlet

 

longchamp bags

 

coach outlet store online

 

eahawks jerseys

 

yeezy boost

 

louboutin shoes

 

jordan uk

 

coach factory outlet online

 

birkenstock

 

tods outlet

 

coach factory outlet

 

louboutin outlet

 

michael kors

 

hermes bags

 

pandora charms sale

 

rolex replica watches for sale

 

polo ralph lauren

 

rolex watches

 

coach outlet online

 

michael kors

 

pandora charms

 

louis vuitton factory outlet

 

mont blanc pens

 

phillies jerseys

 

ed hardy outlet

 

michael kors outlet online

 

fred perry polo shirts

 

ralph lauren outlet

 

longchamp handbags

 

michael kors outlet store

 

nike free run

 

michael kors outlet clearance

 

cheap oakley sunglasses

 

michael kors outlet online

 

nike sneakers

 

49ers jerseys

 

polo ralph lauren outlet

 

nike flyknit

 

rolex watches

 

toms outlet store

 

ralph lauren outlet online

 

cheap ray ban sunglasses

 

cheap jordan shoes

 

coach outlet online

 

fitflops sale

 

adidas yeezy boost

 

michael kors outlet

 

gucci bags

 

true religion jeans outlet

 

fitflops sale clearance

 

longchamp sale

 

adidas yeezy boost

 

louis vuitton outlet online

 

birkenstock shoes

 

michael kors outlet canada

 

swarovski crystals

 

ray ban sunglasses sale

 

cowboys jerseys

 

ralph lauren sale clearance uk

 

mbt

 

polo ralph lauren outlet online

 

nike tn pas cher

 

ghd hair

 

air max

 

pandora jewellery

 

coach factory outlet

 

fred perry polo shirts

 

michael kors outlet store

 

michael kors

 

longchamp bags

 

nfl jerseys wholesale

 

adidas nmd r1

 

michael kors bags

 

lakers jerseys

 

ray ban sunglasses outlet

 

longchamp soldes

 

moncler uk

 

air max 90

 

christian louboutin sale

 

coach outlet online

 

yeezy boost

 

beats headphones

 

cheap nike shoes

 

coach outlet store

 

adidas nmd runner

 

true religion sale

 

rockets jerseys

 

pandora jewelry store

 

coach outlet store online

 

louis vuitton handbags

 

nike air max 95

 

curry shoes

 

mlb jerseys

 

michael kors outlet online

 

oakley sunglasses wholesale

 

michael kors outlet online

 

dolce and gabbana outlet online

 

michael kors outlet canada

 

prada outlet online

 

michael kors outlet store

 

coach outlet online

 

fit flops

 

discount oakley sunglasses

 

adidas nmd runner

 

pandora charms outlet

 

moncler jackets

 

chaussures louboutin

 

texans jerseys

 

lebron shoes

 

red sox jerseys

 

michael kors

 

parada bags

 

air max shoes

 

nike blazer low pas cher

 

pandora jewelry outlet

 

purs jerseys

 

oakley sunglasses outlet

 

dodgers jerseys

 

michael kors bags

 

versace

 

mont blanc pen

 

kate spade purses

 

michael kors bags

 

michael kors outlet store

 

moncler outlet online

 

moncler uk

 

adidas nmd r1

 

louboutin outlet

 

cheap rolex replica watches

 

air max 90

 

fitflops clearance

 

discount oakley sunglasses

 

levis outlet

 

cheap air max

 

adidas nmd r1

 

coach outlet online

 

longchamp handbags

 

yeezy shoes

 

jordan shoes

 

fitflops sale

 

pandora charms outlet

 

ralph lauren uk

 

discount nike shoes

 

coach factory outlet

 

mont blanc pen

 

true religion outlet online

 

adidas superstar shoes

 

nike outlet

 

ralph lauren outlet online

 

adidas uk

 

true religion outlet store

 

nike store

 

polo ralph lauren outlet online

 

true religion outlet store

 

coach factory outlet

 

nike outlet store online

 

birkenstock uk

 

coach outlet online

 

fitflop shoes

 

coach factory outlet online

 

nike cortez classic

 

ray bans

 

michael kors outlet store

 

moncler coats

 

adidas outlet online

 

michael kors uk

 

christian louboutin shoes

 

adidas nmd runner

 

christian louboutin

 

adidas nmd r1

 

louboutin shoes

 

hermes outlet online

 

cubs jerseys

 

polo ralph lauren

 

coach factory outlet online

 

nmd adidas

 

giants jerseys

 

pandora charms

 

kate spade outlet online

 

nfl jerseys wholesale

 

jordans

 

warriors jerseys

 

polo ralph lauren

 

true religion jeans outlet

 

polo ralph lauren

 

birkenstock outlet

 

coach factory outlet

 

gucci outlet online

 

cheap nike sneakers

 

vans outlet

 

mulberry outlet uk

 

cheap jerseys

 

cheap oakley sunglasses

 

ray ban sale

 

white sox jerseys

 

toms outlet

 

coach purses

 

valentino outlet

 

mulberry

 

coach factory outlet online

 

kate spade bags

 

nike roshe shoes

 

mlb jerseys

 

ray ban sunglasses discount

 

coach factory outlet online

 

michael kors outlet online

 

mlb jerseys

 

coach outlet online

 

coach outlet online

 

polo ralph lauren

 

chi flat iron

 

louis vuitton outlet online

 

mulberry handbags

 

adidas superstars

 

fitflop

 

burberry outlet online

 

nfl jerseys cheap

 

kate spade bags

 

coach outlet online

 

christian louboutin sale

 

louboutin outlet

 

ray ban glasses

 

cavaliers jerseys

 

ray ban sunglasses outlet

 

polo ralph lauren outlet

 

michael kors handbags outlet

 

michael kors outlet store

 

nike air max 95

 

yeezy boost 350

 

louboutin pas cher

 

discount oakley sunglasses

 

sac longchamp

 

cheap jordan shoes

 

air jordans

 

michael kors outlet online

 

michael kors outlet store

 

pandora jewelry

 

james shoes

 

coach outlet

 

michael kors handbags outlet

 

nike free 4.0 flyknit

 

true religion uk

 

adidas outlet online

 

michael kors uk

 

pandora outlet

 

yeezy shoes

 

toms

 

michael kors outlet online

 

cheap jordan shoes

 

coach outlet online

 

eltics jerseys

 

polo ralph lauren pas cher

 

polo ralph lauren outlet

 

ralph lauren sale

 

mlb jerseys

 

ralph lauren outlet online

 

longchamp bag

 

adidas yeezy boost

 

polo ralph lauren outlet

 

christian louboutin pas cher

 

coach outlet online

 

hollister clothing

 

pandora charms sale clearance

 

coach outlet store online

 

coach outlet store

 

cheap jerseys

 

michael kors handbags outlet

 

wireless beats headphones

 

kate spade uk

 

coach outlet online

 

oakley sunglasses cheap

 

longchamp outlet store

 

coach outlet online

 

pandora jewellery

 

adidas yeezy boost 350

 

adidas nmd runner

 

true religion jeans outlet

 

pandora charms sale clearance

 

adidas

 

cheap oakley sunglasses

 

coach outlet online

 

toms shoes

 

kate spade outlet online

 

celine handbags

 

yeezy boost 350

 

pandora charms sale clearance

 

mulberry bags

 

coach factory outlet online

 

pandora

 

cheap oakley sunglasses

 

gucci bags

 

beats by dre

 

coach outlet store

 

toms

 

michael kors outlet

 

adidas sneakers

 

coach factory outlet online

 

sac louis vuitton pas cher

 

moncler pas cher

 

patriots jerseys

 

ray ban sunglasses discount

 

longchamp bag

 

michael kors outlet store

 

gucci handbags outlet

 

coach outlet online

 

coach outlet online

 

nike air huarache

 

montblanc pens

 

chaussures louboutin

 

michael kors outlet online

 

coach factory outlet online

 

kate spade outlet online

 

oakley sunglasses outlet

 

nike air force

 

michael kors

 

kd shoes

 

michael kors outlet clearance

 

pandora uk

 

birkenstocks

 

nfl jerseys

 

fred perry shirts

 

oakley sunglasses on sale

 

pandora charms outlet

 

montblanc

 

chaussure louboutin pas cher

 

louis vuitton outlet store

 

rolex replica watches for sale

 

abercrombie outlet

 

pandora jewelry

 

adidas outlet store

 

gucci

 

yeezy boost 350

 

ralph lauren

 

coach outlet

 

red bottom

 

pandora jewelry outlet

 

bulls jerseys

 

coach outlet store

 

coach factory outlet online

 

gucci handbags outlet

 

hollister clothing store

 

polo ralph lauren outlet online

 

nike free run flyknit

 

fit flops

 

fit flops

 

adidas trainers

 

michael kors bags

 

coach outlet store online

 

burberry outlet

 

tigers jerseys

 

air max

 

fitflops sale

 

mulberry uk

 

gucci outlet online

 

longchamps

 

nike roshe one

 

coach factory outlet online

 

tory burch outlet online

 

michael kors outlet store

 

christian louboutin shoes

 

adidas

 

cheap jordan shoes

 

adidas ultra boost

 

coach outlet online

 

ed hardy store

 

broncos jerseys

 

toms

 

louis vuitton outlet store

 

ralph lauren outlet

 

coach factory outlet online

 

vans store

 

nike outlet online

 

ralph lauren sale clearance uk

 

longchamp bags

 

yankees jerseys

 

hollister kids

 

nike air max

 

kobe bryant shoes

 

coach outlet store online

 

michael kors purse

 

ralph lauren outlet

 

adidas trainers

 

adidas superstar trainers

 

fake rolex watches

 

packers jerseys

 

coach outlet online

 

yeezy boost

 

ray ban glasses

 

ed hardy clothing

 

ralph lauren sale

 

nike outlet store

 

true religion jeans outlet

 

pandora charms sale clearance

 

cheap nfl jerseys

 

coach outlet online

 

christian louboutin outlet

 

michael kors outlet store

 

adidas store

 

pandora charms

 

fitflops sale clearance

 

michael kors handbags

 

heat jerseys

 

cheap ray ban sunglasses

 

adidas yeezy boost

 

pandora charms

 

coach outlet online

 

jordan shoes

 

polo ralph lauren outlet

 

gucci borse

 

air max

 

louis vuitton bags

 

louis vuitton outlet online

 

coach factory outlet online

 

hermes bags

 

cheap jordans for sale

 

yeezy 350 boost

 

polo ralph lauren outle

 

red bottom heels

 

adidas superstars

 

michael kors outlet online

 

harden shoes

 

michael kors outlet online

 

nike outlet store

- by 20170419 yueqin on 4/19/2017
Leave a Comment:
Name :
Email : * will not be shown
Title :
Comment :


» Member access