Heim  >  Artikel  >  Web-Frontend  >  jquery实现的导航固定效果_jquery

jquery实现的导航固定效果_jquery

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

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代码


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn