• jquery版固定边栏滚动特效


    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
    *{
    margin: 0;
    }
    #header{
    100%;
    height:200px;
    background-color: #CCCCCC
    }
    #side{
    float: left;
    300px;
    height:500px;
    background-color: #008000;
    }
    #main{
    margin-left: 310px;
    height:5000px;
    background-color: #5449F9;
    }
    #contain{
    position: relative;
    }
    </style>
    </head>
    <body>
    <div id="header">

    </div>
    <div id="contain">

    <div id="side">

    </div>
    <div id="main">

    </div>

    </div>
    </body>
    <script src="js/jquery-1.9.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">
    //方法一:适用无头部型侧边栏
    /*$(window).scroll(function() {
    var windowHeight = $(window).scrollTop() + $(window).height();
    var sideHeight = $('#side').height();
    if (windowHeight > sideHeight) {
    $('#side').css({
    'position' : 'fixed',
    'left' : '0px',
    'top' : -(sideHeight - $(window).height())
    });
    } else {
    $('#side').css({
    'position' : 'static'
    });
    }
    });
    window.onload=function(){
    $(window).trigger('scroll');
    };
    $(window).resize(function(){
    $(window).trigger('scroll');
    })*/
    //方法二:适用有头部型侧边栏
    $(window).scroll(function() {
    var windowHeight = $(window).scrollTop();
    var sideHeight =$('#main').height()-$('#side').height();
    if (windowHeight >200 && windowHeight<sideHeight+200) {
    $('#side').css({
    position : 'absolute',
    left : '0px',
    top: windowHeight-200+'px'
    });
    } else if(windowHeight <=200){
    $('#side').css({
    position: 'absolute',
    left : '0px',
    top: '0px'
    });
    }
    });
    window.onload=function(){
    $(window).trigger('scroll');
    };
    $(window).resize(function(){
    $(window).trigger('scroll');
    })
    </script>
    </html>

  • 相关阅读:
    leveldb的搜索
    分布式存储bfs
    golang channel的行为
    支持rotate和大小限制的golang log库
    后台架构 一些需要注意的地方
    不要滥用面向对象,写出难以阅读和修改的代码
    goloader
    逻辑引擎、工作流、CMDB小感
    HTML5学习笔记4
    HTML5学习笔记3
  • 原文地址:https://www.cnblogs.com/luoguixin/p/6256883.html
Copyright © 2020-2023  润新知