zoukankan      html  css  js  c++  java
  • 在不适用fixed的前提下,当内容较少时footer固定在页面底部

    使用css,参考国外的一个解决方法:

    http://ryanfait.com/resources/footer-stick-to-bottom-of-page/

    How to use the CSS Sticky Footer on your website

    Add the following lines of CSS to your stylesheet. The negative value for the margin in .wrapper is the same number as the height of .footer and .push. The negative margin should always equal to the full height of the footer (including any padding or borders you may add).

    * {
        margin: 0;
    }
    
    html, body {
        height: 100%;
    }
    
    .wrapper {
        min-height: 100%;
        height: auto !important;
        height: 100%;
        margin: 0 auto -4em;
    }
    
    .footer, .push {
        height: 4em;
    }
    

    Follow this HTML structure. No content can be outside of the .wrapper and .footer div tags unless it is absolutely positioned with CSS. There should also be no content inside the .push div as it is a hidden element that "pushes" down the footer so it doesn't overlap anything.

    <html>
        <head>
            <link rel="stylesheet" href="layout.css" ... />
        </head>
        <body>
            <div class="wrapper">
                <p>Your website content here.</p>
                <div class="push"></div>
            </div>
    
            <div class="footer">
                <p>Copyright (c) 2008</p>
            </div>
    
        </body>
    </html>
    

      

      注意:

      1. 注意footer body 的border/padding值会影响显示;

      2. 当页面包含header时 .footer, .push 的设置会随之改变并不相等;

      

  • 相关阅读:
    visual studio 2013 生成依赖项关系图出错
    redHat 安装mono 错误
    redHat 安装mono 错误
    msdn帮助,离线下载
    w
    msdn帮助,离线下载
    vs2013 找不到帮助 help查看器
    vs2013 找不到帮助 help查看器
    c# wpf 加密文本
    c# wpf 加密文本
  • 原文地址:https://www.cnblogs.com/xx0405/p/5254986.html
Copyright © 2011-2022 走看看