Sticky Header using Jquery

Size
2,024 Kb
Views
14,168

How do I make an sticky header using jquery?

A simple sticky header using .addClass and .removeClass. Easy to use.. What is a sticky header using jquery? How do you make a sticky header using jquery? This script and codes were developed by Hélio Marcondes on 09 November 2022, Wednesday.

Sticky Header using Jquery Previews

Sticky Header using Jquery - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Sticky Header using Jquery</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <header> <ul> <li>Home</li> <li>Works</li> <li>Blog</li> <li>Join Us</li> <li>About</li>
</header> <div class="text"> SCROLL IT ^ </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 using Jquery - Script Codes CSS Codes

*{ margin:0; padding:0; list-style:none;
}
body{ height:1000px;
}
header{ position:fixed; width: 100%; text-align: center; font-size: 40px; line-height: 108px; height: 108px; background: #335C7D; color: #fff; font-family: 'PT Sans', sans-serif; transition: all 0.4s ease;
}
header.sticky { text-align: center; font-size: 24px; line-height: 48px; height: 48px; background: #efc47D; padding-left: 20px;
}
ul{ display:inline-block;
}
li{ display:inline-block; padding:0 40px;
}
.text{ text-align:center; font-size:40px; position:absolute; top:140px; left:600px;
}

Sticky Header using Jquery - Script Codes JS Codes

$(window).scroll(function() {
if ($(this).scrollTop() > 1){ $('header').addClass("sticky"); } else{ $('header').removeClass("sticky"); }
});
Sticky Header using Jquery - Script Codes
Sticky Header using Jquery - Script Codes
Home Page Home
Developer Hélio Marcondes
Username haykou
Uploaded November 09, 2022
Rating 3
Size 2,024 Kb
Views 14,168
Do you need developer help for Sticky Header using Jquery?

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!

Hélio Marcondes (haykou) Script Codes
Create amazing art & images with AI!

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!