Hi Paul. Thank you for the reply and explanation. It is more that I do some experiments because I am still struggling with the height property in a responsive design. With the display:table method, do you refer to the post started by felgall?
Edit: I actually found your old demo where you use the display table method:
and I used that method myself before, but I would like to avoid to use a fixed height for the header and footer, but then, logically, I don’t have a reference to use for the negative top margin of the outer div and the padding of the content div. What would be my best option
Thank you indeed Ron. That is indeed close to what I’m looking for. I only would like to align the content div (in the last example main) vertically as well like in this example, where I used Paul’s old demo! What do I need to adjust to accomplish that. I can’t get my head around the display: table, display: table-cell part
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Sticky footer IE8+</title>
<style type="text/css">
html, body {margin:0; padding:0; height:100%;}
body {display:table;width:100%}
.content { background:#ccc; }
.main{display:block}
header { background:#999; color:#fff; text-align:center; padding:10px 0}
header, .footer, main { display:table-row }
/* height 1px on the header and footer is the sticky footer technique */
header, .footer{height:1px}
h1{padding:10px;margin:0;}
.footer {background:#999; color:#fff; text-align:center;}
.footer p { margin:0; padding:10px}
/* vertically align center content */
.inner-content{display:table-cell;vertical-align:middle}
.vertical{
width:50%;
background:rgba(255,255,255,0.4);
margin:auto;
}
</style>
<!-- html5 shiv for IE8 and under -->
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<header><h1>Fluid Height Sticky footer simple - IE8+ (no hacks )</h1></header>
<main class="content">
<div class="inner-content">
<div class="vertical">This is the inner content This is the inner content This is the inner content This is the inner content This is the inner content This is the inner content This is the inner content This is the inner content </div>
</div>
</main>
<footer class="footer"><p>Sticky footer</p></footer>
</body>
</html>
Hi Paul that is indeed what I mean, but what is confusing me somehow is the use of main and .main(class). In the HTML I don’t see a class main? Specially becausse of this property:
Yes you can use the ‘footer’ element as the selector but bear in mind that html allows multiple footer elements so globally styling the footer element is a bit like globally styling ‘div’. The footer (and header) element can be used many times to create structure within sections and do not only apply to the top and bottom of a page. (Although, why they (html5 authors) did this is beyond me as no one ever used them that way before and they said they added these elements because people were using them already.)
Of course if you only have one ‘footer’ element in the page and you know you aren’t going to use another one then it will be ok.
Hi Paul. Thank you so much. This is a real eye openerer :tup: I made a few adjustments so I get the two columns as I needed. Things start to get much clearer now