I am creating a site in which there are a number of fixed background images that you scroll past. Associated with each fixed background is an image slider (or text) that is hidden until the title is clicked on. These items are all fixed positioned.
I was able to make this work by using z-index to place items in order top to bottom/first to last and then have each disappear in turn using:
$(document).scroll(function() {
$('#porttitle').toggle($(this).scrollTop() < 225);
});
However, I am unable to use this because the length pixel distance down on the page changes based on the screen size. I am pretty new to Jquery but wanted to try to use .offset .top to have the item disappear not based on the pixel length to the top of the page but instead when an element appears on the screen. This is what I have so far but it isn’t seeming to work.
$(document).scroll(function() {
$('#porttitle').toggle($(this).scrollTop() < $(âarticle.post-100â).offset().top);
});
Here is the link to the site: http://s416809079.onlinehome.us (not final location – just developing)
Any thoughts?
Thanks!
I think this may work for you, read the comments on the code for a line by line explanation.
Working Example
I’m conditionally changing the opacity rather than using toggle because:
Related documentation:
.offset()
.each()
.scroll()
.scrollTop()