当浏览器滚动条向下滚动,自动悬浮导航栏在最上面。

效果:

导航条悬浮效果

1、 css代码

	.ui-jqgrid-htable{
		z-index: 999;
	}

2、 jquery代码


$(function(){

       var offset_pin = $(".ui-jqgrid-htable").offset();//pin的偏移

        $(window).scroll(function(){//滚动页面 
	        
        var scroH = $(this).scrollTop(); //浏览器偏移
	        
	if(scroH > offset_pin.top){
	        $(".ui-jqgrid-htable").css({ top: "0", position: "fixed"});
	}else{
	        $(".ui-jqgrid-htable").css({ top: "", position: ""});
	}

});

3、 html代码

<div class="ui-jqgrid-htable">
 导航
</div>

@落雨
http://ae6623.cn

相关文章:

  • 2021-06-29
  • 2021-11-02
  • 2021-12-06
  • 2021-08-30
  • 2021-11-02
  • 2021-06-26
  • 2021-11-12
  • 2021-12-19
猜你喜欢
  • 2021-12-19
  • 2021-12-09
  • 2021-11-02
  • 2021-12-25
  • 2020-02-18
  • 2021-12-09
  • 2021-10-18
相关资源
相似解决方案