zoukankan      html  css  js  c++  java
  • 吸顶条或者其他的吧

    <!DOCTYPE html>
    <html>
    <head>
    <style>
    *{margin: 0;padding: 0;list-style: none;}
    body{
    1180px;
    margin: 0 auto;
    }
    .head{
    100%;
    height: 60px;
    background: red;
    }
    .main{
    margin: 30px 0 ;
    height: 100%;
    overflow: hidden;

    }
    .foot{
    100%;
    height: 40px;
    background: #000;
    clear: both;
    }
    .left{
    float: left;
    210px;
    height: 1300px;
    border: 1px solid red;
    background: green;
    }

    .right{
    float: right;
    930px;
    height: 900px;
    border: 1px solid red;
    background: #ccc;

    }
    </style>
    <!--
    <script>
    (function(){
    window.onresize=window.onscroll=window.onload=function (){
    var oDiv=document.getElementById('form-wrap');
    var scrollTop=document.documentElement.scrollTop || document.body.scrollTop;
    var clientHeight=document.documentElement.clientHeight;
    var t=document.body.scrollHeight;
    var bodyH= scrollTop+clientHeight;
    if(Math.abs(bodyH - t ) < 5){
    oDiv.style.bottom='40px';
    }else{
    oDiv.style.bottom='0px';
    }
    };
    })();
    </script>
    -->
    <script>
    window.onload= window.onscroll=function(){
    var oLeft = document.getElementById('left');
    var oRight = document.getElementById('right');
    var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;

    //当left的height最大为right的高
    if(oLeft.offsetHeight >oRight.offsetHeight){
    oLeft.style.height =getStyle(oRight,'height') +'px';
    }

    //当left的scrollTop为0,fixed
    if(scrollTop > oLeft.offsetTop){
    oLeft.style.position ='fixed';
    oLeft.style.top = '0';
    if(oLeft.offsetHeight<oRight.offsetHeight){
    oLeft.style.height =getStyle(oRight,'height') +'px';
    }else{
    oLeft.style.height =document.documentElement.clientHeight -70 +'px';
    }
    }else{
    oLeft.style.position ='';
    }

    function getStyle(obj,name){
    return obj.currentStyle ? obj.currentStyle[name] :getComputedStyle(obj, false)[name];
    }

    }
    </script>
    </head>
    <body>
    <div class="head"></div>
    <div class="main">
    <div class="left" id="left">
    <ul>
    <li>菜单1</li>
    <li>菜单2</li>
    <li>菜单3</li>
    <li>菜单4</li>
    <li>菜单5</li>
    </ul>
    </div>
    <div class="right" id="right">这里是内容</div>
    </div>
    <div class="foot"></div>
    </body>
    </html>

  • 相关阅读:
    Scripts.Render 索引超出了数组界限
    AutoFac使用方法总结
    MFC中打开一个获取路径的对话框
    MFC中自定义消息
    获得窗口句柄的方法
    App Doc View Frame中指针的获取
    MFC中菜单的命令响应顺序
    机械设计软件编写心得
    对SVD奇异值分解的理解
    安装win8+Ubuntu14.04双系统的经验总结
  • 原文地址:https://www.cnblogs.com/heboliufengjie/p/4673732.html
Copyright © 2011-2022 走看看