zoukankan      html  css  js  c++  java
  • css 之 sticky footers 布局

    关于:Sticky footer布局

    我们常见的网页布局方式一般分为header(页头)部分,content(内容区)部分和footer(页脚)部分。当页头区和内容区的内容较少时,页脚区不是随着内容区排布而是始终显示在屏幕的最下方。当内容区的内容较多时,页脚能随着文档流撑开始终显示在页面的最下方。

    参考链接:

    https://www.jianshu.com/p/3853024d5838

    https://www.w3cplus.com/css3/css-secrets/sticky-footers.html

    https://segmentfault.com/a/1190000012794431

    常用方法:负margin布局方式

    html代码:

      <div class="detail">

         <div class="wrapper clearfix">
           <div class="title">
            <h1>这里是头部</h1>
           </div>
           <div class="main">
            <p>这里是main content区域...</p>
            <p>这里是main content区域...</p>
            <p>这里是main content区域...</p>
            <p>这里是main content区域...</p>
           </div>
         </div>
         <div class="footer">
           <p>© 2017 No rights reserved.</p> 
           <p>Made with ♥ by an anonymous pastafarian.</p> 
         </div>
      </div>

    css代码:
      div,h1,p{margin:0; padding: 0;}
     .detail{
          position:fixed;
          overflow:auto;
          width:100%;
          height:100%;
        }
     .wrapper{
          min-height:100%;
          width:100%;
        }
     .title h1{
          font-size:40px;
          text-align: center;
        }
     .main{
          margin-top:64px;
          padding-bottom:64px;
        }
     .main p{
          font-size: 25px; 
          text-align: center;
        }
     .footer{
          margin:-64px auto 0 auto;
          font-size:32px;
        }
     .footer p{
          text-align: center;
        }
     .clearfix::after {
          display: block;
          content: ".";
          height: 0;
          clear: both;
          visibility: hidden;
        }
    注意:main里的 padding-bottom和footer里的负margin值要保持一致。
  • 相关阅读:
    获取系统版本
    一句代码删除所有子视图
    MAJOR-MINOR-MKDEV
    AF_UNIX和AF_INET域的socket在epoll中的差异
    python-print
    python-class(5)
    python-class(4)
    python-class(3)
    python-class(2)
    python-class(1)
  • 原文地址:https://www.cnblogs.com/chm-blogs/p/11508374.html
Copyright © 2011-2022 走看看