Fixed header, fixed dynamic content

I struggle with my dynamic content. So let me explain in the picture:

enter image description here

So my html looks like this:

<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 is: how can I get my container in liquid, and the header and footer will be fixed? The blocks in the container are set to 50% of the height and width, so only the container should be 100% of the height (- fixed header and footer).

+4
source share
4 answers

You can do this with a property box-sizing.

Same:

Fiddle

(the example I'm using here assumes a header height and 64px height 30px height)

Markup

<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>

CSS

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;
}
+7
source

CSS

*{
    margin:0;
    padding:0;
}
#header{
    height:100px;
    background-color:red;
    position:fixed;
    top:0;
    width:100%;
}
#footer{
    height:100px;
    background-color:green;
    position:fixed;
    bottom:0;
    width:100%;
}
#container{
    background-color:#F7F7F7;
    width:100%;
    top:100px;
    position:relative;
}
.block{
    width:50%;
    background-color:gray;
  float:left;
}
+2

float, desgins. width, . width. Danield, , , . , , -.

+2

twitter-bootstrap. Bootstrap:

: http://bootply.com/render/88297

: http://bootply.com/88297

It uses a slightly standard / nav BS header and a fixed footer. Then they are used in the central container table, table-rowand table-cellso that the size of the central blocks corresponds to 50/50.

.center-container {
  height:100%;
  display: table;
  width:100%;
  margin:0;
}

.center-row {
  height:50%;
  width:100%;
  display: table-row;
}

.center-row > div {
  height:100%;
  width:50%;
  display: table-cell;
  border:1px solid #eee
}
+1
source

All Articles