|
|
Forum moderator: bigblog |
uCoz Community For Webmasters Custom Solutions Fade on scrolling down |
Fade on scrolling down |
Hello!
I'm trying to do this on uCoz site, but without any success! https://codepen.io/brightonmike/pen/xnuzg Can you help my? I want to fade my menu as it is fixed to the top! Added (2018-01-24, 8:03 PM) |
Doing this now!
HTML Code <html> <head></head> <body> <div id="main-menu"> MAIN MENU </div> </body> </html> CSS Code #main-menu { background: black; color: white; text-align: center; padding: 4px; position: fixed; left: 0; right: 0; top: 0; } .spacer { height: 22px; } body.scrolled #main-menu { opacity: 0.2; transition: opacity .2s; } body.scrolled #main-menu:hover { opacity: 1.0; transition: opacity .2s; } body { height:5000px; } JS Code window.addEventListener('scroll', function () { document.body.classList[ window.scrollY > 20 ? 'add': 'remove' ]('scrolled'); }); Post edited by jackass - Saturday, 2018-01-27, 8:16 AM
|
| |||
| |||