Guest User

Untitled

a guest
Dec 9th, 2018
451
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <style>
  2. @media (min-width: 992px) {
  3. .fixed-header { padding-top: 202px; }
  4. .fixed-header #header { position: fixed; top: 0; left: 0; width: 100%; background-color: #fff; border-bottom: 1px solid #e3e3e3; padding-bottom: 0 !important; margin-bottom: 0; }
  5. .fixed-header #header .site-name { padding-top: 0; padding-bottom: 0; position: absolute; left: 50%; top: 0; transform: translateX(-50%); z-index: 8; }
  6. .fixed-header #header .site-name img { max-height: 50px; }
  7. .fixed-header #header .top-nav { padding-top: 0; }
  8. }
  9. </style>
  10.  
  11. <script type="text/javascript">
  12. function fixedHeader() {
  13. var offsetTop = $(window).scrollTop();
  14. var fixedClass = 'fixed-header';
  15. var fixedElement = $('body');
  16. var fixedFrom = 0;
  17. var fixedTo = 20;
  18.  
  19. if (offsetTop > fixedFrom) {
  20. fixedElement.addClass(fixedClass);
  21. }
  22.  
  23. if (offsetTop < fixedTo) {
  24. fixedElement.removeClass(fixedClass);
  25. }
  26. }
  27.  
  28. window.onscroll = function () {
  29. console.log($(window).scrollTop());
  30. fixedHeader()
  31. };
  32. </script>
RAW Paste Data