美文网首页
sticky footer

sticky footer

作者: 瓜田猹 | 来源:发表于2017-08-18 15:08 被阅读15次

一种完美的css绝对底部

手机端网页有时候会遇到这种布局要求:当内容很少时,footer位于窗口底部,当内容占满整个屏幕时,footer跟在内容末尾,这时候我们就可以用sticky footer

布局前提:footer要和主体内容div同级

        <div class="main-wrap">
            <div class="main-content  clearfix">  <!--clearfix清楚内容区域里的浮动-->
                <p>我是内容区域</p>
                <p>我是内容区域</p>
                <p>我是内容区域</p>
            </div>
        </div>
        <div class="footer">
            我是底部内容
        </div>

样式:

          * {
               margin: 0;
               padding: 0;
           }
           html,body {
               height: 100%;
           }
           .clearfix:after {
               content: '';
               display: block;
               height: 0;
               line-height: 0;
               clear: both;
               overflow: hidden;
               visibility: hidden;
           }
           .main-wrap {
               min-height: 100%;//设置最小高度
               background: #ccc;
           }
           .main-wrap .main-content {
               padding-bottom: 40px;//必须和footer高度相同
           }
           .footer {
               position: relative;
               z-index: 100;
               height: 40px;
               margin:-40px auto 0 auto;//matgin-top必须和footer高度相同    
               clear:both;
               line-height: 40px;
               text-align: center;
               background: rgba(0,0,0,.5);
               color: #fff;
           }

参考:CSS Sticky Footer: 完美的CSS绝对底部

相关文章

  • web前端-Sticky Footer布局

    什么是Sticky Footer布局 Sticky Footer布局实现的效果是, 当页面中的内容高度小于屏幕高度...

  • sticky footer

    所谓的sticky footer就是指: 当页面内容超出屏幕,页脚模块会像正常页面一样,被推到内容下方,需要拖动滚...

  • sticky footer

    需求 如果页面内容不够长的时候,页脚块粘贴在视窗底部;如果内容足够长时,页脚块会被内容向下推送 实现

  • sticky footer

    一种完美的css绝对底部 手机端网页有时候会遇到这种布局要求:当内容很少时,footer位于窗口底部,当内容占满整...

  • sticky-footer布局的方法

    一、什么是sticky-footer布局?sticky-footer布局是一种经典的布局效果,可概况如下:如果页面...

  • sticky footer布局

    实例 套路 一个展示内容content的容器wrapper 一个展示footer的容器 wrapper设置最小高度...

  • sticky footer 布局

    在网页设计中,sticky footer设计是最古老的和常见的效果之一,大多数人都应该经历过。它可以概括如下:当页...

  • sticky footer 布局

    一、stick footer 布局介绍 文档包括内容区与页脚区。当内容高度未达到视口的高,页脚一直在视口最底部。当...

  • Sticky footer布局

    Sticky Footer布局概括如下:如果页面内容不够长的时候,页脚粘贴在视窗底部;如果内容足够长,页脚会被内容...

  • CSS Sticky Footer

    HTML CSS

网友评论

      本文标题:sticky footer

      本文链接:https://www.haomeiwen.com/subject/tsgolxtx.html