Can someone tell me why top of the #page
where it reads START
remains under header when scrolling back up?
Thanks in advance
CSS:
*
{
margin: 0;
padding: 0;
}
#header, #page, #footer
{
float: left;
display: block;
width: 100%;
}
#header
{
background: #CCCCCC;
}
#default
{
display: block;
height: 100px;
background: #64D989;
}
#sticky
{
display: none;
height: 50px;
background: #D9D164;
}
#footer
{
background: #EEEEEE;
}
JS:
$(document).ready(function ()
{
$(window).bind("scroll", function (e)
{
if ($(document).scrollTop() >= 100)
{
$("#header").css('position', 'fixed');
$("#default").css('display', 'none');
$("#sticky").css('display', 'block');
}
else
{
$("#header").css('position', 'fixed');
$("#sticky").css('display', 'none');
$("#default").css('display', 'block');
}
});
});
HTML:
<div id="header">
<div id="default">I AM DEFAULT HEADER</div>
<div id="sticky">I APPEAR IF SCROLL POSITION > 100px</div>
</div>
<div id="page">
START<br /><br />
CONTENT<br /><br /><br />
CONTENT<br /><br /><br />
CONTENT<br /><br /><br />
CONTENT<br /><br /><br />
CONTENT<br /><br /><br />
CONTENT<br /><br /><br />
CONTENT<br /><br /><br />
CONTENT<br /><br /><br />
CONTENT<br /><br /><br />
CONTENT<br /><br /><br />
CONTENT<br /><br /><br />
CONTENT<br /><br /><br />
CONTENT<br /><br /><br />
CONTENT<br /><br /><br />
CONTENT<br /><br /><br />
CONTENT<br /><br /><br />
CONTENT<br /><br /><br />
CONTENT<br /><br /><br />
END
</div>
<div id="footer">I AM PAGE FOOTER</div>