window.onscroll = function() { 2 var header = document.getElementById('header-1'); 3 if (window.pageYOffset > 100) { 4 header.style.backgroundColor = '#015478'; 5 } else { 6 header.style.backgroundColor = 'transparent'; 7 } 8 } 9
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter