Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i want to make a navigation bar at top while scrolling website like https://web-school.in/ but i cant could anyone please help me... thanx in advance
Posted
Comments
Sinisa Hajnal 17-Feb-15 2:27am    
There are plenty of examples of static content - google around.
Shan Shrestha 17-Feb-15 3:03am    
i google it... but i want a appropriat code with some demo please help
Solai Raja 20-Feb-15 2:14am    
http://www.quackit.com/css/codes/css_floating_menu.cfm
here is one example, you may get some idea.

this CSS markup makes your navbar float. apply such CSS class to your navbar
CSS
.yourheader{
 position: fixed;
 top: 0 px;
 /* some other css styles*/
}
 
Share this answer
 
thanx and eventually i solved this problem by myself and here is a jquery and css of the sticky navigation bar in top of the page while scrolling...

<script type="text/javascript">
$(document).ready(function () {
var stickyNavTop = $('.subMenu').offset().top;
var stickyNav = function () {
var scrollTop = $(window).scrollTop();

if (scrollTop > stickyNavTop) {
$('.subMenu').addClass('sticky');
}
else {
$('.subMenu').removeClass('sticky');
}
};
stickyNav();
$(window).scroll(function () {
stickyNav();
});


});
});



.sticky
{
position:fixed;
width: 100%;
left:0;
right:0;
top:0;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900