I have the following problem.
I created a website with this structure:
<section id="content">
...
</section>
<footer>
...
</footer>
The content has a background image set to be fixed at the bottom. Now, when you scroll down, the image scrolls by the footer. To prevent this from happening, I wrote a short script to automatically set the attachment for scrolling when presenting the footer:
$(document).scroll(function () {
var curpos = $(window).scrollTop();
var fooOffset = $('#foot').offset();
var wh = $(window).height();
if(curpos >= (fooOffset.top-wh) && fix == 0) {
$('#content').css('background-attachment','scroll');
fix = 1;
} else if(curpos < (fooOffset.top-wh) && fix == 1){
$('#content').css('background-attachment','fixed');
fix = 0;
}
});
. IE , Chrome (WebKit , ) . , . , . , .
- ?