Home  >  Article  >  Web Front-end  >  jquery实现的导航固定效果_jquery

jquery实现的导航固定效果_jquery

WBOY
WBOYOriginal
2016-05-16 16:51:081033browse

jquery实现的导航固定效果

复制代码 代码如下:

1.jquery代码, .nav为导航的class
$(function(){ 
  $(window).scroll(function() {
 if($(window).scrollTop()>=250){
  $(".nav").addClass("fixedNav");
 }else{
  $(".nav").removeClass("fixedNav");
 }
  });
});

2.CSS代码
.fixedNav{
 position:fixed;
 top:0px;
 left:0px;
 width:100%;
 z-index:100000;
 _position:absolute;
 _top:expression(eval(document.documentElement.scrollTop));
}

3.HTML代码


Statement:
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