I have a linear gradient at the bottom of the page, which is set by body:before
. Now I want that 75% color stop to change as I scroll down the page, so I have the js/jquery code below. I don't think $("body:before")
works, so how can I fix that, so as I scroll down the color stop gradually goes up too?
html, body {
width: 100%;
height: 100%;
margin: 0px;
}
body:before {
content:'';
position: fixed;
top: 0;
bottom: 0;
width: 100%;
z-index: -1;
background: linear-gradient(to bottom, rgba(0, 0,0,1) 0%, rgba(30,30,30,1) 75%, rgba(180,180,180,1) 100%);
}
Here's the js code:
$(window).scroll(function(){
$("body:before").css({
"background": "linear-gradient(to bottom, rgba(0, 0,0,1) 0%, rgba(30,30,30,1) " + (75 - $(window).scrollTop()/100) + "%, rgba(180,180,180,1) 100%);"
});
});