欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用常見的sticky footer布局方式

  發(fā)布時間:2019-04-17 15:37:25   作者:隨她   我要評論
這篇文章主要介紹了使用常見的sticky footer布局方式的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

什么是sticky footer布局

我們常見的網(wǎng)站頁面都會把一個頁面分為:頭部區(qū)、內(nèi)容區(qū)、頁腳區(qū),當頭部區(qū)和內(nèi)容區(qū)內(nèi)容較少時,頁腳區(qū)能固定在網(wǎng)頁底部,而不是隨著文檔流排布。當頁面內(nèi)容較多時,頁腳能隨著文檔內(nèi)容自動撐開,顯示在頁面的最底部。這就是sticky footer布局。

實現(xiàn)方式

flex 實現(xiàn)

html代碼

<header class="header"></header>
    <main class="content">
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
        <p>近段時間房管局四大金剛</p>
    </main>
    <footer class="footer"></footer>

css代碼

*{
    margin: 0;
    padding: 0;
}
html,body{
    display: flex;
    flex-direction: column;
    min-height: 100%;
    width: 100%;
}
.header{
    background: gray;
    height: 20px;
}
.content{
    flex: 1;
    overflow: auto;
    background: greenyellow;
}
.footer{
    background: pink;
    height: 20px;
}

flex布局方法簡單代碼少,因為pc端兼容性不是很好,可以廣泛用于移動端。

負margin布局方式

html代碼

<div class="wrapper clearfix">
        <div class="title">
            <h1>這里是頭部</h1>
        </div>
        <div class="main">
            <p>近段時間房管局四大金剛</p>
            <p>近段時間房管局四大金剛</p>
            <p>近段時間房管局四大金剛</p>
            <p>近段時間房管局四大金剛</p>
            <p>近段時間房管局四大金剛</p>
            <p>近段時間房管局四大金剛</p>
            <p>近段時間房管局四大金剛</p>
            <p>近段時間房管局四大金剛</p>
            <p>近段時間房管局四大金剛</p>
            <p>近段時間房管局四大金剛</p>
            <p>近段時間房管局四大金剛</p>
            <p>近段時間房管局四大金剛</p>
            <p>近段時間房管局四大金剛</p>
            <p>近段時間房管局四大金剛</p>
            <p>近段時間房管局四大金剛</p>
            <p>近段時間房管局四大金剛</p>
            <p>近段時間房管局四大金剛</p>
            <p>近段時間房管局四大金剛</p>
            <p>近段時間房管局四大金剛</p>
            <p>近段時間房管局四大金剛</p>
        </div>
    </div>
    <div class="footer">
        <p>© 2017 No rights reserved.</p>
        <p>Made with ♥ by an anonymous pastafarian.</p>
    </div>

css代碼

* {
    margin: 0;
    padding: 0;
    text-align: center;
}

.wrapper {
    min-height: 100%;
    width: 100%;
}

.main {
    margin-top: 64px;
    padding-bottom: 64px;
}

.footer {
    margin: -64px auto 0 auto;
    background: orange;
}

.clearfix::after {
    display: block;
    content: ".";
    height: 0;
    clear: both;
    visibility: hidden;
}

這是兼容性最好的方案,各大瀏覽器都可兼容,就是需要提前知道footer的高度。且結(jié)構(gòu)相對復雜。

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • CSS Sticky Footer實現(xiàn)代碼

    這篇文章主要介紹了CSS Sticky Footer實現(xiàn)代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-12-05
  • CSS實現(xiàn)Sticky Footer的示例代碼

    這篇文章主要介紹了CSS實現(xiàn)Sticky Footer的示例代碼的相關(guān)資料,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-01-24
  • 詳解CSS經(jīng)典布局之Sticky footer布局

    這篇文章主要介紹了詳解CSS經(jīng)典布局之Sticky footer布局的相關(guān)資料,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-01-08
  • 詳解Sticky Footer 絕對底部的兩種套路

    這篇文章主要介紹了詳解Sticky Footer 絕對底部的兩種套路,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-11-03

最新評論