Guest User

Untitled

a guest
Nov 16th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.40 KB | None | 0 0
  1. <header class="nb-header row-fluid">
  2. <div class="container-fluid">
  3. <div class="nb-logo row-fluid">
  4. <a href="#">
  5. logo
  6. </a>
  7. </div>
  8. <div class="nb-hamburger">
  9. Hamburger
  10. </div>
  11. </div>
  12. </header>
  13. <!--nb-header-->
  14. <div class="nb-menu-bar row-fluid">
  15. <div class="container-fluid">
  16. <ul>
  17. <li> <a href="#"> <span class="nb-menu-link"> Work </span> <span class="nb-menu-sub">
  18. What we’ve done </span> </a>
  19. </li>
  20. <li> <a href="#"> <span class="nb-menu-link"> Services </span> <span class="nb-menu-sub">
  21. What we do </span> </a>
  22. </li>
  23. <li> <a href="#"> <span class="nb-menu-link"> Studio </span> <span class="nb-menu-sub">
  24. Who we are </span> </a>
  25. </li>
  26. <li> <a href="#"> <span class="nb-menu-link"> Contact </span> <span class="nb-menu-sub">
  27. Get in touch </span> </a>
  28. </li>
  29. <li> <a href="#"> <span class="nb-menu-link"> Careers </span> <span class="nb-menu-sub">
  30. Join the team </span> </a>
  31. </li>
  32. </ul>
  33. </div>
  34. </div>
  35. Showing/hiding any HTML DOM element is a common scenario based on various business requirements. Since the time
  36. of SPA (single page application) is evolved, you will find that on scroll position of browser, new elements are
  37. shown and previous elements are hidden. There are tons of jQuery plugins available which can show/hide any HTML
  38. element based on the scroll position but it’s not advisable to use jQuery plugins for things which you can do
  39. with simple jQuery code. So in this post, let’s see how to show/hide any HTML element based on the scroll
  40. position in the browser window using jQuery.Showing/hiding any HTML DOM element is a common scenario based on
  41. various business requirements. Since the time of SPA (single page application) is evolved, you will find that
  42. on scroll position of browser, new elements are shown and previous elements are hidden. There are tons of
  43. jQuery plugins available which can show/hide any HTML element based on the scroll position but it’s not
  44. advisable to use jQuery plugins for things which you can do with simple jQuery code. So in this post, let’s
  45. see how to show/hide any HTML element based on the scroll position in the browser window using
  46. jQuery.Showing/hiding any HTML DOM element is a common scenario based on various business requirements. Since
  47. the time of SPA (single page application) is evolved, you will find that on scroll position of browser, new
  48. elements are shown and previous elements are hidden. There are tons of jQuery plugins available which can
  49. show/hide any HTML element based on the scroll position but it’s not advisable to use jQuery plugins for
  50. things which you can do with simple jQuery code. So in this post, let’s see how to show/hide any HTML element
  51. based on the scroll position in the browser window using jQuery.Showing/hiding any HTML DOM element is a common
  52. scenario based on various business requirements. Since the time of SPA (single page application) is evolved,
  53. you will find that on scroll position of browser, new elements are shown and previous elements are hidden.
  54. There are tons of jQuery plugins available which can show/hide any HTML element based on the scroll position
  55. but it’s not advisable to use jQuery plugins for things which you can do with simple jQuery code. So in this
  56. post, let’s see how to show/hide any HTML element based on the scroll position in the browser window using
  57. jQuery.Showing/hiding any HTML DOM element is a common scenario based on various business requirements. Since
  58. the time of SPA (single page application) is evolved, you will find that on scroll position of browser, new
  59. elements are shown and previous elements are hidden. There are tons of jQuery plugins available which can
  60. show/hide any HTML element based on the scroll position but it’s not advisable to use jQuery plugins for
  61. things which you can do with simple jQuery code. So in this post, let’s see how to show/hide any HTML element
  62. based on the scroll position in the browser window using jQuery.Showing/hiding any HTML DOM element is a common
  63. scenario based on various business requirements. Since the time of SPA (single page application) is evolved,
  64. you will find that on scroll position of browser, new elements are shown and previous elements are hidden.
  65. There are tons of jQuery plugins available which can show/hide any HTML element based on the scroll position
  66. but it’s not advisable to use jQuery plugins for things which you can do with simple jQuery code. So in this
  67. post, let’s see how to show/hide any HTML element based on the scroll position in the browser window using
  68. jQuery.Showing/hiding any HTML DOM element is a common scenario based on various business requirements. Since
  69. the time of SPA (single page application) is evolved, you will find that on scroll position of browser, new
  70. elements are shown and previous elements are hidden. There are tons of jQuery plugins available which can
  71. show/hide any HTML element based on the scroll position but it’s not advisable to use jQuery plugins for
  72. things which you can do with simple jQuery code. So in this post, let’s see how to show/hide any HTML element
  73. based on the scroll position in the browser window using jQuery.Showing/hiding any HTML DOM element is a common
  74. scenario based on various business requirements. Since the time of SPA (single page application) is evolved,
  75. you will find that on scroll position of browser, new elements are shown and previous elements are hidden.
  76. There are tons of jQuery plugins available which can show/hide any HTML element based on the scroll position
  77. but it’s not advisable to use jQuery plugins for things which you can do with simple jQuery code. So in this
  78. post, let’s see how to show/hide any HTML element based on the scroll position in the browser window using
  79. jQuery.Showing/hiding any HTML DOM element is a common scenario based on various business requirements. Since
  80. the time of SPA (single page application) is evolved, you will find that on scroll position of browser, new
  81. elements are shown and previous elements are hidden. There are tons of jQuery plugins available which can
  82. show/hide any HTML element based on the scroll position but it’s not advisable to use jQuery plugins for
  83. things which you can do with simple jQuery code. So in this post, let’s see how to show/hide any HTML element
  84. based on the scroll position in the browser window using jQuery.Showing/hiding any HTML DOM element is a common
  85. scenario based on various business requirements. Since the time of SPA (single page application) is evolved,
  86. you will find that on scroll position of browser, new elements are shown and previous elements are hidden.
  87. There are tons of jQuery plugins available which can show/hide any HTML element based on the scroll position
  88. but it’s not advisable to use jQuery plugins for things which you can do with simple jQuery code. So in this
  89. post, let’s see how to show/hide any HTML element based on the scroll position in the browser window using
  90. jQuery.
  91. Showing/hiding any HTML DOM element is a common scenario based on various business requirements. Since the time
  92. of SPA (single page application) is evolved, you will find that on scroll position of browser, new elements are
  93. shown and previous elements are hidden. There are tons of jQuery plugins available which can show/hide any HTML
  94. element based on the scroll position but it’s not advisable to use jQuery plugins for things which you can do
  95. with simple jQuery code. So in this post, let’s see how to show/hide any HTML element based on the scroll
  96. position in the browser window using jQuery.
  97. Showing/hiding any HTML DOM element is a common scenario based on various business requirements. Since the time
  98. of SPA (single page application) is evolved, you will find that on scroll position of browser, new elements are
  99. shown and previous elements are hidden. There are tons of jQuery plugins available which can show/hide any HTML
  100. element based on the scroll position but it’s not advisable to use jQuery plugins for things which you can do
  101. with simple jQuery code. So in this post, let’s see how to show/hide any HTML element based on the scroll
  102. position in the browser window using jQuery.
  103. Showing/hiding any HTML DOM element is a common scenario based on various business requirements. Since the time
  104. of SPA (single page application) is evolved, you will find that on scroll position of browser, new elements are
  105. shown and previous elements are hidden. There are tons of jQuery plugins available which can show/hide any HTML
  106. element based on the scroll position but it’s not advisable to use jQuery plugins for things which you can do
  107. with simple jQuery code. So in this post, let’s see how to show/hide any HTML element based on the scroll
  108. position in the browser window using jQuery.
  109. Showing/hiding any HTML DOM element is a common scenario based on various business requirements. Since the time
  110. of SPA (single page application) is evolved, you will find that on scroll position of browser, new elements are
  111. shown and previous elements are hidden. There are tons of jQuery plugins available which can show/hide any HTML
  112. element based on the scroll position but it’s not advisable to use jQuery plugins for things which you can do
  113. with simple jQuery code. So in this post, let’s see how to show/hide any HTML element based on the scroll
  114. position in the browser window using jQuery.
  115. Showing/hiding any HTML DOM element is a common scenario based on various business requirements. Since the time
  116. of SPA (single page application) is evolved, you will find that on scroll position of browser, new elements are
  117. shown and previous elements are hidden. There are tons of jQuery plugins available which can show/hide any HTML
  118. element based on the scroll position but it’s not advisable to use jQuery plugins for things which you can do
  119. with simple jQuery code. So in this post, let’s see how to show/hide any HTML element based on the scroll
  120. position in the browser window using jQuery.
  121. Showing/hiding any HTML DOM element is a common scenario based on various business requirements. Since the time
  122. of SPA (single page application) is evolved, you will find that on scroll position of browser, new elements are
  123. shown and previous elements are hidden. There are tons of jQuery plugins available which can show/hide any HTML
  124. element based on the scroll position but it’s not advisable to use jQuery plugins for things which you can do
  125. with simple jQuery code. So in this post, let’s see how to show/hide any HTML element based on the scroll
  126. position in the browser window using jQuery.
  127.  
  128. .nb-header {
  129. position: fixed;
  130. top: 0;
  131. right: 0;
  132. bottom: auto;
  133. left: 0;
  134. width: 100% !important;
  135. background:#fff200;
  136. padding: 12px 0;
  137. z-index: 1000;
  138. @media(max-width: 767px) {
  139. padding: 15px 0;
  140. }
  141. .nb-logo {
  142. width: 45px;
  143. float: left;
  144. }
  145. .nb-logo a {
  146. display: block;
  147. }
  148. .nb-logo img {
  149. display: block;
  150. }
  151. }
  152.  
  153. .nb-hamburger {
  154. float: right;
  155. cursor: pointer;
  156. transition: all 0.6s;
  157. }
  158.  
  159. .nav-up {
  160. top: -75px;
  161. }
  162.  
  163. .nb-menu-bar {
  164. text-align: center;
  165. display: none;
  166. background: #fff200;
  167. position: fixed;
  168. z-index: 100;
  169. // right:0;
  170. // top: 0;
  171. // left: 0;
  172. // width: 100%;
  173.  
  174. ul {
  175. padding: 50px 0;
  176. margin-top: 70px;
  177. @media(min-width: 767px) {
  178. padding: 200px 0;
  179. }
  180. }
  181.  
  182.  
  183. li {
  184. display: block;
  185. margin: 25px 20px 0 20px;
  186. @media(min-width: 767px) {
  187. display: inline-block;
  188. vertical-align: middle;
  189. margin: 0 20px 0 20px;
  190. }
  191.  
  192. @media(min-width:800px) {
  193. margin: 0 20px 0 20px;
  194. }
  195.  
  196. @media(min-width:1100px) {
  197. margin: 0 30px 0 30px;
  198. }
  199.  
  200. }
  201.  
  202. a {
  203. display: block;
  204. font-size: 25px;
  205. color: #1b1b1c;
  206. font-weight: 700;
  207.  
  208. @media(min-width:800px) {
  209. font-size: 28px;
  210. }
  211.  
  212. @media(min-width:1100px) {
  213. font-size: 36px;
  214. }
  215.  
  216. span.nb-menu-sub {
  217. font-size: 15px;
  218. color: #4a4a4a;
  219. display: block;
  220. font-weight: $primary-weight;
  221. margin-top: 5px;
  222. @media(min-width: 991px) {
  223. font-size: 18px;
  224. margin-top: 15px;
  225. }
  226. }
  227.  
  228. }
  229.  
  230. span.nb-menu-link {
  231. position: relative;
  232. z-index: 1;
  233. &::before {
  234. content: '';
  235. height: 5px;
  236. width: 0;
  237. display: inline-block;
  238. border-radius: 2px;
  239. background: #fff200;
  240. position: absolute;
  241. left: 0;
  242. bottom: 5px;
  243. z-index: -1;
  244. transition: all 0.5s;
  245. }
  246. }
  247.  
  248. a:hover span.nb-menu-link:before {
  249. width: 100%;
  250. }
  251.  
  252.  
  253.  
  254.  
  255. }
  256.  
  257.  
  258.  
  259.  
  260. .hamburger-content {
  261. display: none;
  262. background: #0000;
  263. }
  264.  
  265. .hamburger-container {
  266. display: inline-block;
  267. padding: 15px 0 15px 15px;
  268. margin-left: 20px;
  269. cursor: pointer;
  270. }
  271.  
  272. .hamburger-grid {
  273. width: 20px;
  274. transition: all 0.5s;
  275. }
  276.  
  277. .hamburger-line {
  278. height: 2px;
  279. width: 20px;
  280. display: block;
  281. background: #000;
  282. margin-top: 5px;
  283. }
  284.  
  285.  
  286. var didScroll;
  287. var lastScrollTop = 0;
  288. var delta = 5;
  289. var navbarHeight = $('header').outerHeight();
  290.  
  291. $(window).scroll(function(event){
  292. didScroll = true;
  293. });
  294.  
  295. setInterval(function() {
  296. if (didScroll) {
  297. hasScrolled();
  298. didScroll = false;
  299. }
  300. }, 250);
  301.  
  302. function hasScrolled() {
  303. var st = $(this).scrollTop();
  304.  
  305. // Make sure they scroll more than delta
  306. if(Math.abs(lastScrollTop - st) <= delta)
  307. return;
  308.  
  309. // If they scrolled down and are past the navbar, add class .nav-up.
  310. // This is necessary so you never see what is "behind" the navbar.
  311. if (st > lastScrollTop && st > navbarHeight){
  312. // Scroll Down
  313. $('header').removeClass('nav-down').addClass('nav-up');
  314. } else {
  315. // Scroll Up
  316. if(st + $(window).height() < $(document).height()) {
  317. $('header').removeClass('nav-up').addClass('nav-down');
  318. }
  319. }
  320.  
  321. lastScrollTop = st;
  322. }
Add Comment
Please, Sign In to add comment