smooth sticky header - Free Download Smooth Sticky Header In jQuery - sp.stickyHeader.js

Free Download Smooth Sticky Header In jQuery – sp.stickyHeader.js

Posted on

This time I will share jQuery Plugin and tutorial about Smooth Sticky Header In jQuery – sp.stickyHeader.js, hope it will help you in programming stack.

smooth sticky header - Free Download Smooth Sticky Header In jQuery - sp.stickyHeader.js
File Size: 3.44 KB
Views Total: 1149
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

A lightweight, customizable, smooth, mobile-compatible sticky header plugin created using jQuery, CSS transitions, and CSS position: fixed property.

With the sp.stickyHeader.js plugin, developers can quickly create a smart sticky header navigation on the webpage.

For guidance on how to create sticky elements using JavaScript or Pure CSS, see: 10 Best Sticky Header Navigation Systems.

How to use it:

1. Link to jQuery library and the sp.stickyHeader.js plugin’s files in the document.

1 <link rel="stylesheet" href="/path/to/css/sp.stickyHeader.css" />
2 <script src="/path/to/cdn/jquery.slim.min.js"></script>
3 <script src="/path/to/js/sp.stickyHeader.js"></script>

2. Create a header element as follows:

1 <header id="demo-header">
2   <section class="header-top">
3     Will Be Hidden When The Navbar Is Sticky
4   </section>
5   <section class="navbar">
6     Will Be Sticky On Page <a href="https://www.jqueryscript.net/tags.php?/Scroll/">Scroll</a>
7   </section>
8 </header>

3. Attach the plugin to the header element and we’re done.

1 $('#demo-header').spSticyheader({
2   hideHeaderTarget: '.header-top'
3 })

4. Determine how far the page is scrolled down to make the header element sticky. Defaults to 300.

1 $('#demo-header').spSticyheader({
2   scrollHeader: 200
3 })

5. Add additional CSS class(es) to the header element when stuck.

1 $('#demo-header').spSticyheader({
2   customClass: 'make-small'
3 })

6. Determine whether to disable the sticky header on mobile devices. Defaults to true.

1 $('#demo-header').spSticyheader({
2   mobileHeader: false
3 })