flex实现经典的sticky footer布局

  1. 需求分析:当页面内容小于设备屏幕的高度时,底部footer部分固定在屏幕底部,当页面内容超出屏幕高度时,底部footer部分随页面变动,始终在页面的底部。
flex布局实现

html部分

<body>
    <header class="header-wrapper">标题部分</header>
    <section class="cont-wrapper">内容部分</section>
    <footer class="foot-wrapper">版权信息</footer>
</body>

css部分

 html,body,header,footer,section,div,p{
    padding:0;
    margin:0;
}

html{
    height:100%;
}
body{
    display:flex;
    display:-webkit-box; 
    height:100%;
    flex-direction:column;
}
.header-wrapper{
    width:100%;
    height:45px;
    line-height:45px;
    background:#abcdef;
    text-align:center;
    font-size:0.3rem;
    color:#333;
}
.cont-wrapper{
    font-size:0.3rem;
    flex: 1 0 auto;
}
.foot-wrapper{
    width:100%;
    height:48px;
    line-height:48px;
    text-align:center;
    background:#ccc;
    font-size:0.3rem;
    flex: 0 0 auto;
}
兼容布局实现

html 部分

<div class="detail">
        <div class="detail-wrapper clearfix">
            <div class="detail-main"></div>
        </div>
        <div class="detail-close">
            <i class="icon-close"></i>
        </div>
</div>

css部分

.detail{
        position:fixed;
        left:0;top:0;
        width:100%;
        height:100%;
        z-index:100;
        overflow:auto;
        transtion:all 0.5s;
        background:rgba(7,17,28,0.8);
        .detail-wrapper{
            width:100%;
            min-height:100%;
            .detail-main{
                matgin-top:64px;
                padding-bottom:64px;
            }
        }
        .detail-close{
            position:relative;
            width:32px;
            height:32px;
            margin:-64px auto 0;
            font-size:32px;
            clear:both;
        }
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值