Reputation: 85
I saw an transparent theme navbar that have really nice effect when scrolling down.
Here is what happends when scrolling down.
Here is direct link to demo page of that theme
Guessing it is javascript/jquery that is used there and i know only HTML & CSS. Could anyone help me make it similar like in that theme?
Upvotes: 3
Views: 13998
Reputation: 442
Ok, I'm gonna throw you a bone here JSFiddle:
$(document).on('scroll', function (e) {
$('.navbar').css('opacity', ($(document).scrollTop() / 500));
});
Magic number alert: 500 is the divider for the scrollTop, the lower the number the faster the opacity goes above 1 (opacity should be between 0 and 1.
So what this code does is listen to scrolling on the document and set the opacity of the navbar according to the scroll position.
Hope this helps!
Upvotes: 6