Fixed navigation effects implemented by jquery
- 2020-03-30 02:44:40
- OfStack
Fixed navigation effects implemented by jquery
1.jquery code , .nav For navigation class
$(function(){
$(window).scroll(function() {
if($(window).scrollTop()>=250){
$(".nav").addClass("fixedNav");
}else{
$(".nav").removeClass("fixedNav");
}
});
});
2.CSS code
.fixedNav{
position:fixed;
top:0px;
left:0px;
width:100%;
z-index:100000;
_position:absolute;
_top:expression(eval(document.documentElement.scrollTop));
}
3.HTML code
<div class="nav">
<p> Navigation fixed </p>
</div>