In my website I want to show a particular div in the top of the page, only when the user scroll down. When the user go on top page, this particular div have to disappear.
How can I activate the css rule on scroll page?
.particular-div{
.....
not show on top rules
....
}
.particular-div-on-scroll-down{
set the div on fixed top position;
top:0px; position :fixed;
}
How can I do? I have to use javascript? Thank you
UPGRADE: this is my code, but it is not working:
CSS
@media only screen and (max-device-width: 480px) {
.shares{
top:-100px;left: 0px;
position:fixed;
background:#efe3af;
}
.sharesShow{
top:0px;left: 0px;
}
}
Javascript:
<script>
$(document).ready(function () {
$(window).scroll(function () {
if ($(window).scrollTop() + $(window).height() > $(window).height() + 10) {
$("div.shares").addClass("sharesShow");
} else {
$("div.shares").removeClass("sharesShow");
}
});
});
</script>