You can create sticky footer using css perfectly. Use following css code for creating the sticky footer. Many people gave example of google sticky footer.
create sticky footer using css or javascript
create sticky footer using css or javascript
Use bellow CSS code.
19
height
:
100px
; //You must need to know your footer height
21
margin-bottom
:
-100px
; //here I am thinking footer will be
100
px
You can change the footer height as per your need or footer height.
Sticky footer you will also achieve using javscript code.
04
document.body.onload =
function
() {
05
var
myWidth = 0, myHeight = 0;
06
if
(
typeof
( window.innerWidth ) ==
'number'
) {
08
myWidth = window.innerWidth;
09
myHeight = window.innerHeight;
10
}
else
if
( document.documentElement &&
11
( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
13
myWidth = document.documentElement.clientWidth;
14
myHeight = document.documentElement.clientHeight;
15
}
else
if
( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
17
myWidth = document.body.clientWidth;
18
myHeight = document.body.clientHeight;
20
window.alert(
'Width = '
+ myWidth );
21
window.alert(
'Height = '
+ myHeight );
23
middle_container = myWidth - 150;
24
document.getElelmentByID(
"main"
).style.height = middle_container;
You just need to minus the header and footer height from middle_container.
Great post. However, I think you should use myHeight in line 21 (middle_container = myWidth – 150;)
Based on your idea, I did this with JQuery (been #expansor a div inside #container.
$(document).ready( function () {
var myHeight = $(window).height();
var contenidoHeight= $(“#container”).height();
var footHeight = $(“#footer”).height();
$(“#expansor”).height(myHeight – contenidoHeight – footHeight ) ;
});