zoukankan      html  css  js  c++  java
  • 对网页中层的固定

    前几天在对网页页面进行布局的时候,遇到一个需要将网页的最下面一个层固定起来,不随网页的滚动条滚动,添加减少浏览器的菜单也不会变动的需求。对于DIV+CSS不熟悉的我,为此加班加点在项目上线时把问题解决了。参考代码如下:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html"; charset="GBK"/>
    <title>固定上下层的位置</title>
    <style type="text/css">
    <!--
    body
    {
    background-image
    : url(0);
    background-attachment
    : fixed;
    }
    #BottomNav
    {
    background
    : #9F6;
    z-index
    : 999;
    position
    : fixed;
    bottom
    : 0;
    left
    : 0;
    width
    : 100%;
    height
    : 30px;
    position
    :fixed;
    top
    : expression(documentElement.scrollTop + documentElement.clientHeight-this.offsetHeight);
    overflow
    : visible;
    }

    #topNavWrapper
    {
    height
    : 30px;
    margin
    : 0px auto;
    width
    :100%;
    z-index
    :100;
    position
    :fixed ;
    top
    :0px;
    left
    :0;
    background
    : #9F6;
    }
    #center
    {
    width
    : 100%;
    height
    :100%;
    padding-top
    :30px;
    padding-bottom
    :30px;

    }
    -->
    </style>
    </head>
    <body>
    <div id="topNavWrapper">固定悬浮导航在此处,不随滚动条的滚动变化</div>
    <div id="center">
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    <p>我是中间层</p>
    </div>
    <div id="BottomNav">固定悬浮导航在此处,,不随滚动条的滚动变化</div>
    </body>
    </html>


     

  • 相关阅读:
    游记&退役记
    Nothing to say
    学习知识点的比较好的blog
    计划做题列表
    后缀自动机小专题
    复数
    FFT学习
    P2900 [USACO08MAR]土地征用Land Acquisition
    # 数位DP入坑
    Hdu 4035 Maze(概率DP)
  • 原文地址:https://www.cnblogs.com/xhwy/p/2236979.html
Copyright © 2011-2022 走看看