0

Changing css according to scroll using JavaScript or jQuery!

I have seen many examples of changing CSS styles according to scrolling. I have tried many times to do so but never been able to do it dynamically like just every little bit of scroll would change a bit of CSS styles. Can anyone pls share the code for this thing with a bit of explaination?

10th Jul 2017, 12:56 PM
Avi_Roy
Avi_Roy - avatar
2 odpowiedzi
+ 14
onload = function() { document.body.style.height = "300%"; document.body.style.background = "black"; }; onscroll = function() { document.body.style.background = "#"+Math.round(scrollY*(255/(innerHeight*2))).toString(16)+"0000"; }; //Scroll page up and down
10th Jul 2017, 1:14 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 1
Thanx man
10th Jul 2017, 2:35 PM
Avi_Roy
Avi_Roy - avatar