Template:Team:DTU-Denmark/css3

From 2014.igem.org

(Difference between revisions)
Line 477: Line 477:
}
}
}
}
-
 
+
#ScrollMenu.fixed {
 +
    position: fixed;
 +
    top: 0;
 +
    left: 0;
 +
    z-index: 1;
 +
    width: 100%;
 +
    border-bottom: 5px solid #ffffff;
 +
}
</style>
</style>
-
<script src="https://2014.igem.org/Team:DTU-Denmark/StickyNav.js?action=raw"></script>
+
<script>
 +
$(document).ready(function () { 
 +
  var top = $('#ScrollMenu').offset().top - parseFloat($('#ScrollMenu').css('marginTop').replace(/auto/, 100));
 +
  $(window).scroll(function (event) {
 +
    // what the y position of the scroll is
 +
    var y = $(this).scrollTop();
 +
 
 +
    // whether that's below the form
 +
    if (y >= top) {
 +
      // if so, ad the fixed class
 +
      $('#ScrollMenu').addClass('fixed');
 +
    } else {
 +
      // otherwise remove it
 +
      $('#ScrollMenu').removeClass('fixed');
 +
    }
 +
  });
 +
});
 +
</script>
</html>
</html>

Revision as of 11:27, 24 July 2014