RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
             footer     

min-height实在是超级好用的一个css属性了,搭配flex轻松实现沉底效果。

方法3 巧用flex + margin-top

这个技巧是在讲margin auto的妙用中学到的,在flex格式化上下文中,margin auto会自动去分配剩余空间。这里面我们可以在footer上使用margin-top:auto来达到沉底效果。



    footer沉底效果
    
        div {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            position: relative;
        }
        html, body {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }
        #container {
            width: 100%;
            min-height: 100%;
            display: flex;
            flex-direction: column;
        }
        #content {
            background: blue;
        }
        #footer {
            width: 100%;
            height: 100px;
            background: red;
            margin-top: auto; // 重点代码
        }
    




     
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
        content  
    
             footer     

以上是“网站footer沉底效果的三种解决方案”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!


当前题目:网站footer沉底效果的三种解决方案
标题网址:http://jxjierui.cn/article/gejpje.html
Top