I have seen a few similar to what I am looking for but not exactly the same.
So what I am trying to do is move elements from within one parent div to another but only once the user has scrolled a certain amount down the page. So once the user has reached a point on the page the elements will then move to another and then fade in at the very top of the page.
So far I have been able to create the div element and get this to show at the top of the page but only once the user has scrolled down 600. What I now need to do is once this element appears to move other div elements on the page to appear within it. Not sure if I am explaining this very well or not!
So if you look at the code below what I want to do now is to move all of the div class "Test" to move within the element of "Top" once the user has scrolled down and this appears. And then if the user scrolls back up again the "Top" element disappears and the "Test" div goes back to it's normal place.
Code:
<div id="Top"></div>
<div class="Test">
<h1 class="heading-title">Title Here</h1>
<div class="product-price">Price Here</li>
<div class="cart-container"><button type="button" id="button-cart"
class="button">Add to Cart</button></div>
</div>
<style type="text/css">
#Top {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
border-bottom: 2px solid #f2f2f2;
border-radius: 0;
background-color: rgb(255, 255, 255);
z-index: 9999;
padding: 15px;
}
</style>
<script>
$(document).scroll(function () {
var y = $(this).scrollTop();
if (y > 600) {
$('#Top').fadeIn();
} else {
$('#Top').fadeOut();
}
});
</script>
برچسب:
نویسنده: آیلین رضوانی
تاريخ: چهارشنبه
20 دی
1396 ساعت: 7:09