4
As is done this fixed menu at the top of the page that when the user scrolls down the screen when arriving at a particular page location the menu decreases getting compact. And by turning the screen up the menu goes back to the initial styling? This can be done with the logo too?
Example taken from the Website: https://builtwith.com/
To fix the menu I’m using
position: fixed;
However, I don’t know how this effect is being realized whether it is Javascript or css.
Using the information obtained here i manage to make the menu bar have an animation, however the animation only applies to the menus, but that’s not quite what I want and what the answers below proposed. I want to have this "animation" effect on my logo as well. Could someone help me?
$(window).scroll(function() {
if ($(document).scrollTop() > 50) {
$('nav').addClass('shrink');
} else {
$('nav').removeClass('shrink');
}
});
body {
padding-top: 50px;
}
nav a {
padding-top: 20px !important;
padding-bottom: 20px !important;
font-size: 18px;
}
nav .navbar-toggle {
margin: 13px 15px 13px 0;
}
.navbar-brand {
font-size: 30px;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
}
nav.navbar.shrink {
min-height: 35px;
}
nav.shrink a {
padding-top: 10px !important;
padding-bottom: 10px !important;
font-size: 15px;
}
nav.shrink .navbar-brand {
font-size: 25px;
}
nav.shrink .navbar-toggle {
padding: 4px 5px;
margin: 8px 15px 8px 0;
}
*Position logo*/ .navbar-brand img {
padding: 10px 0;
}
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img src="https://d2z0lf9itclnw8.cloudfront.net/img/logo/[email protected]" width="250px" class="img-responsive" alt="">
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav pull-right">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</nav>
div class="jumbotron">
<div class="container">
<h1>Hello, world!</h1>
<p>This is a template for a simple marketing or informational website. It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
<p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more »</a></p>
</div>
</div>
<div class="container">
<!-- Example row of columns -->
<div class="row">
<div class="col-md-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
<div class="col-md-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
<div class="col-md-4">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
</div>
<!-- /.container -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
To do this effect, we use Javascript and CSS. This example I think is what you want: Header Resize.
– Douglas Garrido
I’m looking here Douglas. I did several searches on google, however I did not know the name to produce this effect so I had to come here to ask.
– Renato Lazaro
This is exactly what Douglas was looking for if he can formulate his answer I’ll give an upvote.
– Renato Lazaro
Hello friend see on the link the option in practice with bootstrap of the effect you want to hopefully aggregate to formulate your project ! Bootstrap method
– Rblima
@Rblima This example is basically what my above CSS and Javascript code does, but I haven’t gotten the desired result so far.
– Renato Lazaro