Check Out The Latest Themes And Exclusive Deals And Offers On Themes
In Our Deals For Web Developers Section


Join Today And Get All The 87 Themes In Just $69! Join Today

Sticky Footer Using jQuery And CSS

Saturday, Jan 21, 2017

Tags:- jQuery CSS HTML


Sticky Footer is always be the main issue in web design it is difficult to create a footer that always remain in bottom and function properly and same on different screen sizes we solve that problem. In this tutorial we will show you how to create sticky footer using jQuery and CSS.You may also like sticky header using jQuery And CSS.


See Demo
Sticky Footer Using jQuery And CSS


To Create Sticky Footer It Takes Only Two Steps:-

  1. Make a HTML file and define markup and scripting
  2. Make a CSS file and define styling


Step 1.Make a HTML file and define markup and scripting

We make a HTML file and save it with a name footer.html

<html>
<head>
<link rel="stylesheet" type="text/css" href="footer_style.css">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
 var footer_height=$("#footer").height();
 $("#wrapper").css({'padding-bottom' : footer_height});
});
</script>
</head>
<body>
<div id="header">
 <p>TalkersCode.com</p>
</div>

<div id="wrapper">
 <h1>Sticky Footer Using CSS And jQuery</h1>
</div>

<div id="footer">
 <p>TalkersCode.com</p>
</div>
</body>
</html>

In this step we create three div for header, content and footer and we add document.ready() function to get footer height and set that height to wrapper padding to adjust the padding dynamically.You may also like auto scrolling page using jQuery.



Step 2.Make a CSS file and define styling

We make a CSS file and save it with a name footer_style.css

body
{
 text-align:center;
 width:100%;
 margin:0 auto;
 padding:0px;
 font-family:helvetica;
 min-height: 100%;
 position: relative;
 background-color:#BCA9F5;
}
#header
{
 background-color:#8258FA;
 height:70px;
 line-height:70px;
 font-size:35px;
 color:white;
}
#wrapper
{
 text-align:center;
 margin:0 auto;
 padding:0px;
 width:995px;
 position: relative;
 padding-bottom: 70px;
}
h1
{
 margin-top:100px;	
 color:#8258FA;
 font-size:45px;
}
h1 p
{
 font-size:16px;
}
#footer 
{
 position: absolute;
 bottom: 0;
 width: 100%;
 left: 0px;
 height: 70px;
 background-color:#8258FA;
 color:white;
}
#footer p
{
 margin-top:15px;
 font-size:30px;
}

In this step we add the position 'relative' to our body tag and wrapper tag and then add position 'absolute' to our footer to make our footer stick to bottom.You may also like smooth scrolling to div using jQuery.



Thats all, this is how to create sticky footer using jQuery and CSS.You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.

Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email