Sticky header
How do I make an sticky header?
What is a sticky header? How do you make a sticky header? This script and codes were developed by Milano_O on 11 December 2022, Sunday.
Sticky header - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Sticky header</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ body { height: 1200px; margin: 0; padding: 0;
}
.my-header { position: fixed; line-height: 60px; top: 30px; width: 100%; background: indianred; -webkit-transition: all 0.4s ease-in-out; -moz-transition: all 0.4s ease-in-out; -ms-transition: all 0.4s ease-in-out; -o-transition: all 0.4s ease-in-out; transition: all 0.4s ease-in-out; border-bottom: 1px solid #e8e8e8;
}
.my-header .main-nav ul { float: right;
}
.my-header .main-nav ul li { float: left; padding: 0 20px 0 0;
}
.my-header .logo { float: left; padding: 0 20px;
}
.my-header.sticky-header { top: 0; padding: 10px 0; margin: 0 auto; height: 60px; background: #333; -webkit-transition: all 0.4s ease-in-out; -moz-transition: all 0.4s ease-in-out; -ms-transition: all 0.4s ease-in-out; transition: all 0.4s ease-in-out;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <div class="my-header"> <nav class="main-nav"> <ul> <li>Link1</li> <li>Link2</li> <li>Link3</li> <li>Link4</li> </ul> </nav> <div class="logo">LOGO</div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Sticky header - Script Codes CSS Codes
body { height: 1200px; margin: 0; padding: 0;
}
.my-header { position: fixed; line-height: 60px; top: 30px; width: 100%; background: indianred; -webkit-transition: all 0.4s ease-in-out; -moz-transition: all 0.4s ease-in-out; -ms-transition: all 0.4s ease-in-out; -o-transition: all 0.4s ease-in-out; transition: all 0.4s ease-in-out; border-bottom: 1px solid #e8e8e8;
}
.my-header .main-nav ul { float: right;
}
.my-header .main-nav ul li { float: left; padding: 0 20px 0 0;
}
.my-header .logo { float: left; padding: 0 20px;
}
.my-header.sticky-header { top: 0; padding: 10px 0; margin: 0 auto; height: 60px; background: #333; -webkit-transition: all 0.4s ease-in-out; -moz-transition: all 0.4s ease-in-out; -ms-transition: all 0.4s ease-in-out; transition: all 0.4s ease-in-out;
}
Sticky header - Script Codes JS Codes
$(window).scroll(function() { if ($(this).scrollTop() > 1) { $('.my-header').addClass("sticky-header"); } else { $('.my-header').removeClass("sticky-header"); }
});
Developer | Milano_O |
Username | milanodituti |
Uploaded | December 11, 2022 |
Rating | 3 |
Size | 2,716 Kb |
Views | 14,168 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Materialize | 2,578 Kb |
Acorrdian 2016 | 3,720 Kb |
Svg basic | 2,844 Kb |
HTML-and-CSS-slide-out-navigation | 2,963 Kb |
A Pen by milano_O | 2,969 Kb |
Slide menu tn | 2,819 Kb |
Svetiljke | 2,667 Kb |
Organizing Data with Tables | 2,049 Kb |
Siema slider | 3,541 Kb |
Online-store-header | 4,917 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Em Test | Rodesco | 1,784 Kb |
Nice textured background | Hans | 2,659 Kb |
Tree growth tests | Orchard | 3,818 Kb |
CSS 3D Radio buttons | Andreasnylin | 1,650 Kb |
Draggables in pure angular | Rlo206 | 5,167 Kb |
Direction-icon | Alexandremasy | 3,323 Kb |
Mostly Fluid | Mccreath | 3,308 Kb |
Update CSS Variables with JS | Wesbos | 2,335 Kb |
Light Switch | Bartuc | 4,933 Kb |
Importable Clearfix | Corysimmons | 1,411 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!