Christian Van Voorst Christian Van Voorst - 1 month ago 7x
CSS Question

Fixed navbar with animation

I'm trying to make a fixed navbar, that shrinks a bit when you scroll,(something like this: and i've got the navbar fixed and everything, but I can't get the animation to work properly

Can anyone get me started?



Should be super simple @Christian. Just work with offset() and scrollTop() functions from jQuery lib (if you can).

$(document).ready(function() {
  var NavTop = $('.nav').offset().top;
  var Nav = function() {
    var scrollTop = $(window).scrollTop();
    if (scrollTop > NavTop) { 
    } else {


  $(window).scroll(function() {

With regards animation -- transition should do the trick! Ask if you need example, post your code.