Lapys
Lapys

Reputation: 87

Div disappearing behind footer

My problem is that I am trying to make a little image gallery with an option to scroll. If I set a size for the height of the gallery, then it will look incredibly awkward on bigger monitors with a bunch of space below it.

I think the bigger issue is that I've made a lot of adjustments to the whole website just to make sure the footer works, and I definitely don't like how it's implemented, though at this stage I don't see another way. So for now I guess I really just want help with the gallery working, though if anyone has any suggestions for making footers work in future sites, I'd love suggestions.

All right, here's my HTML:

<body>

<div id="container">

<div id="content_wrapper">

    <div id="header">

    </div>

    <div id="content">
    <div id="gallery">

</div>
    </div>
</div>
</div>

<div id="footer_wrapper">
    <div id="footer">
    </div>
</div>

</body>

And here's the relevant CSS:

html, body {
    height: 100%;
}

img {
    padding: 0;
    margin: 0;
}

#content {
    height: auto;
    position: fixed;
    width: 100%;
    float: left;
    overflow: auto;
    margin: 0;
    display: block;
}



#gallery {
    height: 400px;
    width: 770px;
    background-color: rgba(247,247,247,0.8);
    margin: 0.5em auto;
    padding: 0.5em 0;
    overflow: auto;
}

#gallery img {
    width: 150px;
    height: 120px;
    margin: 0.2em 1em;
    border: solid;
    border-color: #00F;
    border-width: 1px;
}

body {
    margin: 0;
    padding: 0;
    color: #FFF;
    background-size: cover;
}

#container {
    width: 100%;
    min-height: 100%;
    height: auto !important;
    height: 100%;
    margin: 0px 0px 0px 0px; /* was: 0 0 -43 0 */
    overflow: fixed;
}

#content_wrapper {
    width: 100%;
    margin: 0px 0px -41px 0px;
    padding-top: 40px;
    height: 100%;
    overflow: fixed;
}

#header {
    background-size: cover; 
    height: 7em;
    box-shadow: 4px 2px 5px #000;
    border-top: 2px solid #F8F8F8;
    border-bottom: 2px solid #F8F8F8;
}

#footer {
    position: relative;
    z-index: 10;
    height: 4em;
    margin-top: -4.07em;
    background-color: #FFF;
    clear: both;
    background-color: #2A64A7;
    border-top: 2px solid #F8F8F8;
}

Sorry for all the code, but I'm kind of at my wit's end. Whenever I fiddle with something, it gets lost behind the footer, or it doesn't look good on a big screen. I'll keep this up to date with anything I figure out.

Thanks in advance for any advice. Thanks!

Upvotes: 1

Views: 2608

Answers (2)

Ryan Sparks
Ryan Sparks

Reputation: 309

Use the

z-index

attribute. Items with a higher z-index get shown on top.

Upvotes: 1

Danield
Danield

Reputation: 125651

Try something like this: (I slightly changed your markup)

FIDDLE

Markup

<div id="header">

</div>
<div id="container">
    <div id="content">
    <div id="gallery">
</div>
    </div>
</div>


<div id="footer">
</div>

CSS

#container
{
    height: 100%;
    margin: -7em 0 -4em;
    padding: 7em 0 4em;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
#content {
    overflow:auto;
    height:100%;
}
#header
{
    position: relative;
    z-index:1;
    background-size: cover; 
    height: 7em;
    box-shadow: 4px 2px 5px #000;
}
#footer
{

    position: relative;
    z-index: 10;
    height: 4em;
    background-color: #FFF;
    clear: both;
    background-color: #2A64A7;
}

Upvotes: 1

Related Questions