I am looking for a way to apply an opacity/rgba color to all content of my page as it reaches a certain distance from the top and bottom of the page.
This is what I want to achieve:
http://www.piccante.co/images/fadeout.png
In the above example, an absolute-positioned gradient is above the text at the bottom, giving the illusion that the text is fading out. However, this is not an option for me as I am using a background image on my page. So for this project, I need to use jQuery to fade out content within a specific div as it gets closer to the top of the page, and also to fade from the bottom.
I also need to make sure that the entire div isn't fading out when reaching a certain point, it needs to just be the content at the top as it passes the viewport either up or down.
Is this possible?
thanks for the help
EDIT: Further details -
I have a fixed header and footer, and want to get the main body content to fade out/in as it comes up into the viewport from the bottom and leaves at the top. The header/footer have clear backgrounds so the content of the main body doesn't hide behind them.
<body>
<header>Header</header>
<div class="main">
Lorem ipsum dolor
</div>
<footer>Footer</footer>
</body>