I'm struggling with my dynamic content. So let me explain in a picture:
So my html looks like:
<div id="header"> ... </div>
<div id="container">
<div class="block"> ... </div>
<div class="block"> ... </div>
<div class="block"> ... </div>
<div class="block"> ... </div>
</div>
<div id="footer"> ... </div>
My question: How can I get my container be fluid and the header and footer be fixed? The blocks in the container are set on 50% height and width, so only the container has to be the 100% height (- the fixed header and footer).
You can do this with box-sizing
property.
Like so:
FIDDLE
(the example I use here assumes a header of 64px height and footer of 30px height)
<header>header</header>
<div class="container">
<div id="content">
<div class="block">block1</div><!--
--><div class="block">block2</div><!--
--><div class="block">block3</div><!--
--><div class="block">block4</div>
</div>
</div>
<footer>footer</footer>
html,body
{
height: 100%;
}
header,footer,div
{
width: 100%;
}
.container
{
height: 100%;
background: pink;
margin: -64px 0 -30px;
padding: 64px 0 30px;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#content {
overflow:auto;
height:100%;
}
.block
{
width: 50%;
height: 50%;
display: inline-block;
border: 1px solid yellow;
-moz-box-sizing: border-box;
box-sizing: border-box;
text-align: center;
}
header
{
height: 64px;
background: purple;
position: relative;
z-index:1;
}
footer
{
height: 30px;
background: gray;
position: relative;
z-index:1;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With