Home > Web Front-end > JS Tutorial > body text

Navigation fixed effect implemented by jquery_jquery

WBOY
Release: 2016-05-16 16:51:08
Original
1075 people have browsed it

Navigation fixed effect implemented by jquery

Copy code The code is as follows:

1.jquery code, .nav is the 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


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template