user2135867
user2135867

Reputation:

divs are displaying behind footer

im using this css code:

/* status update page style */
#content_wrapper {
    display: inline;
    width: 80%;
    padding: 0;
    margin: 0 auto;
}
#content_update {
    display: block;
    float: left;
    padding: 20px;
    margin-top:20px;
    width: 100%;
    background-color: #eee;
    border-radius: 10px; 
    box-shadow: 0 1px 6px rgba(0,0,0,0.5);
}
#content_maintainance {
    display: block;
    float: left;
    padding: 20px;
    margin-top:20px;
    width: 100%;
    background-color: #eee;
    border-radius: 10px; 
    box-shadow: 0 1px 6px rgba(0,0,0,0.5);
}
#content_sidebar {
    display: block;
    float: right;
    width: 230px;
    padding: 20px;
    background-color: #eee;
    border-radius: 10px; 
    box-shadow: 0 1px 6px rgba(0,0,0,0.5);
}

/* FOOTER */
#footer {
    width:100%;
    height:580px;
    position:absolute;
    bottom:0;
    left:0;
    border-top:4px solid #ed1c24;
    background-color:#eeeeee;
}

#footer-inner {
    width:80%;
    margin:0 auto 0 auto;
    height:inherit;
}
#footerTop {
    width:100%;
    height:480px;
    padding-top:10px;
    border-bottom:2px #000000 solid;
}
#footerTopLeft {
    width:30%;
    height:420px;
    float:left;
    display:inline;
    margin-top:10px;
    padding:0 15px 10px 15px;
    border-right:1px solid #000000;
}
#footerTopMid {
    width:30%;
    height:420px;
    float:left;
    display:inline;
    margin-top:10px;
    padding:0 15px 10px 15px;
    border-right:1px solid #000000;
}
#footerTopRight {
    width:30%;
    height:420px;
    float:left;
    display:inline;
    padding:0 15px 10px 15px;
}

but the divs are displaying behind the footer divs. i have created a fiddle here so you can see the html too - http://jsfiddle.net/wmrhC/

Upvotes: 2

Views: 2431

Answers (3)

Pieter VDE
Pieter VDE

Reputation: 2235

As stated in other answers, it's because you've positioned your footer div to be fixed. Something along this line (regarding HTML and CSS) should help for your page lay-out: JSFiddle demo

This is the CSS (see the JS Fiddle for the full code):

...
.wrapper {
    position: relative;
    float: left;
    left: 5.00%;
    width: 90.00%;
    background-color: #cccccc
}
.left1 {
    position: relative;
    float: left;
    left: 0.50%;
    width: 32.00%;
    background-color: #ccccff
}
.left2 {
    position: relative;
    float: left;
    left: 1.50%;
    width: 32.00%;
    background-color: #ccccff
}
.right {
    position: relative;
    float: right;
    right: 0.50%;
    width: 32.00%;
    background-color: #ccccff
}
.footer {
    position: relative;
    float: left;
    left: 5.00%;
    width: 90.00%;
    margin: 10px 0px;
    background-color: #cfcfcf
}
...

As you can see, none of these items are positioned absolute or fixed.

Be sure to check this link too, which explains how you can create a sticky footer: CSS Sticky footer (As indicated by another answer).

Upvotes: 0

Mathijs Flietstra
Mathijs Flietstra

Reputation: 12974

It's because you have set the footer div to be absolutely positioned at the bottom of the browser window with a height of 580px. This takes the div out of the regular document flow, which means other elements can start hiding behind it, and since it is 580px high, most other elements on the page will hide behind it. You could fix this by setting the z-index on the footer to -1, but that's probably not what you are after, as it would just mean that the div's will start floating over the top of the footer instead of behind the footer, and that still doesn't look pretty.

You should get rid of the absolute positioning which you have set currently, and maybe look at something like CSS sticky footer for an approach which will let you set a footer which sticks to the bottom of the page instead of to the bottom of the browser window.

Upvotes: 1

Matyas
Matyas

Reputation: 13702

When working with position: absolute or fixed you should always be aware that these elements can cover other parts of your site, and you have to manage their depth manually

You can do this using the z-index property.

Let's say that you would like that the footer part appears below all contents.

You could add the z-index property like this:

#footer {
  /* other styles */
  z-index: -1;
}

See it in action

Though note, that this only fixes the "content is displayed behind" problem. But looking at your page you have more positioning problems to solve.

Upvotes: 0

Related Questions