+ 2
I want to add a background to the top nav of the page on scroll, anybody could help me!
10 Respostas
+ 2
window.onscroll = function(){
if (window.scrollY > 80) {
document.querySelector("header").style.background = "red";
}else{
document.querySelector("header").style.background = "none";
}
}
This might help you you can replace 80 with height of your header tag
+ 3
Hi! If you have created such a beautiful website, then you should be able to do it
+ 2
are you having trouble saving and displaying the picture? or something else?
+ 2
very cool site! did you make it yourself?
+ 1
Yeah! I created it myself, just help if you can, long story short bro!
+ 1
Nope! just the top nav background on scroll...
+ 1
Thanks bro! It works fine now.
+ 1
you could make it smoother by adding in css:
header {
transition:background-color 0.7s;
}
+ 1
Yeah! I created it myself, and I am still working on it... Please like my code.
0
bookmark