jquery opacity demo
http://stackoverflow.com/questions/11948803/making-one-div-scroll-in-front-of-another
HTML
<div id="header">
<img src="http://davesizer.com/blogs/wp-content/uploads/2010/03/eva_jump.jpg" alt="Dog">
</div>
<div id="wrapper">
<div id="outer">
<div id="content"></div>
</div>w</div>
CSS
html,
body
{
margin:0;
width:100%;
}
#header
{
position:fixed;
top:0;
left:0;
width:100%;
height:auto;
background-size:100%;
}
#header img
{
width:100%;
display:block;
z-index:99;
}
#wrapper
{
width:100%;
background-color:lightgrey;
z-index:100;
position:absolute;
}
#outer
{
margin:30px auto;
padding-top:20px;
position:relative;
width:90%;
height:1500px;
background-color:red;
}
#inner
{
margin:0 auto;
width:200px;
height:250px;
background-color:lightblue;
top:20px
}
JavaScript
$(document).ready(function() {
var header_h = $('#header').height();
$('#wrapper').css('margin-top', header_h + 'px');
$(window).scroll(function() {
var header = $('#header');
var opac = Math.max(0, 1 - $(window).scrollTop() / header.height());
header.css('opacity', opac);
//console.log(opac, $(window).scrollTop(), header.height());
});
});