zoukankan      html  css  js  c++  java
  • 上滑绝对定位

    .fixedBar {
        z-index: 1010;
        position: fixed;
        top: 40px;
        left: 0;
         100%;
        height: 50px;
    }
    
    var titleFix = {
        init:function(){
    		this.titles = $(".yk-box .yk-head .yk-TitleBar");
    		this.len = this.titles.length;
    		this.now = -1;
    		if(this.len <= 0) return false;
    		this.bind();
        },
    	bind:function (){
    		var _this = this;
    	    $(window).on("touchmove scroll resize orientationchange",function(){
    			var nowTop = $(window).scrollTop()+40;// 40:height of the header
    			var now=-1;
    			for(var i=0;i<_this.len;i++){
    				var otop = _this.titles[i].parentNode.offsetTop;				
    				if(nowTop >= otop){
    					now = i;					
    				}
    			}
    			if(_this.now == now) return;			
    			if(now != -1){
    				_this.titles.eq(now).addClass("fixedBar");
    			}
    			_this.titles.eq(_this.now).removeClass('fixedBar');
    			_this.now = now;		
    		});
    	}
    };
    
    
    titleFix.init();
    
  • 相关阅读:
    druid 基本配置
    计算机组成
    数据结构
    shell编程练习
    java之Nio
    java集合深入学习
    mysql学习
    tomcat学习
    大数据面试题
    计算机网络复习
  • 原文地址:https://www.cnblogs.com/scale/p/7777573.html
Copyright © 2011-2022 走看看