zoukankan      html  css  js  c++  java
  • 固定导航栏

    <style>
    .layui-header{height:60px}
    #head-pad{height:60px}
    .
    fixed-header{position:fixed;top:0;right:0;left:0}
    </style>
    <div class="layui-header" id="dmt-front-header"></div>

    let dmtHead = {
      DMTFRONTHEAD : 'dmt-front-header'
    }

    //获取窗口卷去高度
    dmtHead.getBrowerScrollTop = function(){
    return document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
    };

    //创建占位的headPad元素
    dmtHead.createHeadPadEl = function(){
    return $("<div id='head-pad' style="height:60px"></div>");
    };

    //固定头
    dmtHead.fixedHead = function(){
    let _self = this
    ,$frontHeader = $("#"+this.DMTFRONTHEAD)
    ,$headPad = this.createHeadPadEl();
    $(window).on('scroll',function(){
    if(_self.getBrowerScrollTop()>0){
    if(!$frontHeader.hasClass('fixed-header')) {
    $frontHeader.addClass('fixed-header');
    $frontHeader.before($headPad);
    }
    }else{
    if($frontHeader.hasClass('fixed-header')) {
    $headPad.remove();
    $frontHeader.removeClass('fixed-header');
    }
    }
    });
    };
  • 相关阅读:
    发送 GET 和 POST 请求
    日志记录帮助类
    常用正则表达式
    获取验证码
    C# 生成二维码
    android sql Cursor
    sql 语句操作
    android 界面悬浮框实现
    android activity四种启动模式
    andorid 自定义view属性declare-styleable
  • 原文地址:https://www.cnblogs.com/littleboyck/p/13668096.html
Copyright © 2011-2022 走看看