0
I’m trying to get my navbar to change when I scroll down. So far, I have the following HTML code:
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header page-scroll">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<img src="img/portfolio/logopequeno.png" style="display:inline" class="img-responsive">
<a class="navbar-brand" style="display:inline" href="#page-top"> TEXTO EXEMPLO</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="hidden">
<a href="#page-top"></a>
</li>
<li class="page-scroll">
<a href="#portfolio">COMO FUNCIONA</a>
</li>
<li class="page-scroll">
<a href="#about">ASSISTA</a>
</li>
<li class="page-scroll">
<a href="#contact">APOIE</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
And javascript:
$(function() {
$('body').on('click', '.page-scroll a', function(event) {
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top
}, 1500, 'easeInOutExpo');
event.preventDefault();
});
});
When I scroll down, the navbar and the text "EXAMPLE TEXT" get smaller, but the image is not changed.
What I would like to do is to do the scroll down, make the text disappear and get only the image, but smaller size (50% of the original)
It is possible?
Create classes (e.g. .img-resposive-scrolldown) and add/remove in the elements that will be changed every time the scroll moves, checking its top attribute to validate.
– Lucas Fontes Gaspareto
Can you show me how to do it in the code I posted? I still don’t understand javascript very well
– Felipe