zoukankan      html  css  js  c++  java
  • Sticky Footer (让页脚永远停靠在页面底部,而不是根据绝对位置)

    <!doctype html>
    <html>
    <head>
    <meta charset="UTF-8">
    <meta name="Author" content="胡超">
    <title>super胡</title>
    <style>
    * {
    margin:0;
    padding:0;
    }
    html,body, #wrap
    {
    height: 100%;
    }
    body > #wrap
    {
    height: auto;
    min-height: 100%;
    }
    #main
    {
    padding-bottom: 150px;
    } /* must be same height as the footer */
    #footer {
    position: relative;
    margin-top: -150px; /* negative value of footer height */
    height: 150px;
    clear:both;
    border-color:1px solid red;
    background:red;
    }
    /* CLEAR FIX*/
    .clearfix:after
    {content: ".";
    display: block;
    height: 0;
    clear: both;
    visibility: hidden;
    }
    .clearfix {display: inline-block;
    }
    /* Hides from IE-mac */
    .clearfix { height: 1%;/*zoom:1*/
    }

    </style>
    </head>
    <body>
    <div id="wrap">
    <div id="main" class="clearfix">
    </div>
    </div>
    <div id="footer"> sagsdhgdf
    </div>
    </body>
    </html>
    你会发现,页脚的高度在这里被重复使用了三次,这是至关重要的,而且三个高度必须使用同样的值。wrap <div>的height属性把自己拉伸至窗口全部高度的尺寸,负的margin会把footer提高到main <div>的padding的位置上去,因为main已经在wrap的里面,所以main的padding已经是wrap 100%高度的一部分。 这样,footer就留在页面的底部了。

    现在还不算完成,我们还需要去clearfix main <div>。
    .clearfix:after {content: ".";
    display: block;
    height: 0;
    clear: both;
    visibility: hidden;}
    .clearfix {display: inline-block;}
    /* Hides from IE-mac */
    * html .clearfix { height: 1%;}

  • 相关阅读:
    golang 二进制转十进制实现方式
    mysql select column default value if is null
    MySQL 忘记root密码解决方法,基于Ubuntu 14.10
    ecshop 修改记录20150710
    mac os x 10.9.3 升级到10.10.4 记录
    View requires API level 14 (current min is 8): <GridLayout>
    android开发过程中遇到的坑
    如何为网站设置站点图标
    seq 显示00 01的格式
    lvs realserver 配置VIP
  • 原文地址:https://www.cnblogs.com/12606huchao/p/4878759.html
Copyright © 2011-2022 走看看