經(jīng)典頁面布局學(xué)習(xí)

總結(jié)幾種常用的頁面布局

  1. 上中下布局
<!DOCTYPE html>
<!--上中下布局-->
<html lang="en">
<style>
    body {
        margin: 0
    }

    .wrap {
        width: 900px;
        /* 居中 */
        margin: 0 auto; 
        font-size: 20px;
        /* 文字居中 */
        text-align: center;
    }

    #header {
        height: 100px;
        background: #6cf;
    }

    #main {
        height: 500px;
        background: #ccffff
    }

    #footer {
        height: 80px;
        background: #9cf
    }
</style>

<head>
    <meta charset="UTF-8">
    <title>我的修煉</title>
</head>

<body>
    <header id="header" class='wrap'>#header</header>
    <section id="main" class='wrap'>#section</section>
    <footer id="footer" class='wrap'>#footer</footer>
</body>

</html>

頁面運(yùn)行效果:


上中下
  1. 左右兩欄布局
<!-- 左右兩欄布局 -->
<html lang='en'>

<head>
    <meta charset="UTF-8">
    <title>左右兩欄布局</title>
    <style>
        body {
            margin: 0px;
        }

        .wrap {
            width: 900px;
            margin: 0 auto;
        }

        #left {
            width: 200px;
            /* 向左浮動(dòng) */
            float: left;
            height: 500px;
            background: #ccffff;
        }

        #right {
            /* 自適應(yīng)寬度 */
            margin-left: 200px;
            background: #ffcccc;
            height: 500px;
        }
    </style>
</head>
</head>

<body>
    <div class="wrap">
        <aside id="left">left</aside>
        <section id="right">rigth</section>
    </div>
</body>

</html>

頁面運(yùn)行效果:


左右兩欄布局
  1. 左右兩欄純浮動(dòng)實(shí)現(xiàn)
    寬度固定森瘪,不能自適應(yīng)
<!-- 純浮動(dòng)實(shí)現(xiàn)方案 -->
<html lang='en'>

<head>
    <meta charset="UTF-8">
    <title>左右兩欄布局</title>
    <style>
        body {
            margin: 0px;
        }

        .wrap {
            width: 900px;
            margin: 0 auto;
            /* 清除浮動(dòng) */
            overflow: hidden; 
        }

        #left {
            width: 200px;
            float: left;
            height: 500px;
            background: #ccffff;
        }

        #right {
            width: 700px;
            background: #ffcccc;
            height: 500px;
            float: right;
        }
    </style>
</head>
</head>

<body>
    <div class="wrap">
        <aside id="left">left</aside>
        <section id="right">right</section>
    </div>
</body>

</html>

頁面運(yùn)行效果:

純浮動(dòng)實(shí)現(xiàn)方案
  1. 左右頁眉頁腳布局
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>左右頁眉頁腳布局</title>
    <style>
        .wrap {
            width: 900px;
            margin: 0 auto;
        }
        header{
            height: 200px;
            background: #72418f;
        }
        #main {
            overflow: hidden;
        }
        #left {
            float: left;
            width:200px;
            background: #4f9655;
            height: 400px;
        }
        #right { 
            float: right;
            width: 700px;
            background: #1337ad;
            height: 400px;
        }
        footer {
            height: 180px;
            background: #e6bc02;
            /* clear:both */
        }
    </style>
</head>
<body>
    <div class="wrap">
        <header>header</header>
        <div id='main'>
            <aside id='left'>left</aside>
            <section id='right'>rigth</section>
        </div>
        <footer>footer</footer>
    </div>
</body>
</html>

頁面運(yùn)行效果:

左右頁眉頁腳布局
  1. 左中右三欄布局
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>左中右3欄布局</title>
    <style>
        .wrap {
            /* 根據(jù)屏幕的寬度自適應(yīng) */
            width: 80%; 
            margin: 0 auto;
            height: 700px;
        }

        #left {
            float: left;
            width: 200px;
            height: 100%;
            background: #d4a6a6;
        } 

        #center {
            height: 100%;
            margin: 0 210px;
            background: #68d646;
        }

        #right {
            float:right;
            width:200px; 
            height: 100%;
            background: #3014cc
        }
    </style>
</head>

<body>
    <div class="wrap">
        <section id="left"></section>
        <section id="right"></section>
        <section id="center"></section>
    </div>
</body>

</html>

頁面運(yùn)行效果:


左中右
  1. 左中右三欄之雙飛翼
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>左中右三欄之雙飛翼</title>
    <style>
        .wrap {
            width: 80%;
            margin: 0 auto;
        }

        #main {
            float: left;
            width: 100%;
        }

        #content { 
            background: #e7890e;
            height: 500px;
            margin: 0 200px;
        }

        #left {
            float: left;
            width: 200px;
            height: 500px;
            background: #52d814;
            margin-left: -100%;
        }

        #right {
            float: left;
            width: 200px;
            height: 500px;
            background: #3110a8;
            margin-left: -200px;
        }
    </style>
</head>

<body>
    <div class="wrap">
        <section id="main">
            <div id="content">content</div>
        </section>
        <aside id="left">left</aside>
        <aside id="right">right</aside>
    </div>
</body>

</html>

頁面運(yùn)行效果:


雙飛翼布局

7: 左中右三欄加頁眉頁腳

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>左中右三欄加頁眉頁腳</title>
    <style>
        .wrap {
            margin: 0 auto;
            width: 80%
        }

        #header {
            height: 100px;
            background: #9dcf80
        }

        #main {
            height: 500px;
        }

        #footer {
            height: 80px;
            background: #5b79df;
        }

        #middle {
            float: left;
            width: 100%;
            background: #262341;
        }

        #left {
            float: left;
            height: 500px;
            width: 200px;
            background: #99609e;
            margin-left: -100%;
        }

        #right {
            float: left;
            height: 500px;
            width: 200px;
            background: #99609e;
            margin-left: -200px;
        }

        #content {
            height: 500px;
            margin: 0 200px;
        }
    </style>
</head>

<body>
    <header id="header" class="wrap"></header>
    <section id="main" class="wrap">
        <div id="middle">
            <section id='content'></section>
        </div>
        <aside id='left'></aside>
        <aside id="right"></aside>
    </section>
    <footer id="footer" class="wrap"></footer>
</body>

</html>

頁面運(yùn)行效果:


左中右三欄加頁眉頁腳
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末吭敢,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌趣斤,老刑警劉巖讨衣,帶你破解...
    沈念sama閱讀 216,591評(píng)論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異没炒,居然都是意外死亡涛癌,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,448評(píng)論 3 392
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來拳话,“玉大人先匪,你說我怎么就攤上這事∑埽” “怎么了呀非?”我有些...
    開封第一講書人閱讀 162,823評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長镜盯。 經(jīng)常有香客問我岸裙,道長,這世上最難降的妖魔是什么形耗? 我笑而不...
    開封第一講書人閱讀 58,204評(píng)論 1 292
  • 正文 為了忘掉前任哥桥,我火速辦了婚禮,結(jié)果婚禮上激涤,老公的妹妹穿的比我還像新娘拟糕。我一直安慰自己,他們只是感情好倦踢,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,228評(píng)論 6 388
  • 文/花漫 我一把揭開白布送滞。 她就那樣靜靜地躺著,像睡著了一般辱挥。 火紅的嫁衣襯著肌膚如雪犁嗅。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,190評(píng)論 1 299
  • 那天晤碘,我揣著相機(jī)與錄音褂微,去河邊找鬼。 笑死园爷,一個(gè)胖子當(dāng)著我的面吹牛宠蚂,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播童社,決...
    沈念sama閱讀 40,078評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼求厕,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了扰楼?” 一聲冷哼從身側(cè)響起呀癣,我...
    開封第一講書人閱讀 38,923評(píng)論 0 274
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎弦赖,沒想到半個(gè)月后项栏,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,334評(píng)論 1 310
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡腾节,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,550評(píng)論 2 333
  • 正文 我和宋清朗相戀三年忘嫉,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了荤牍。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,727評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡庆冕,死狀恐怖康吵,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情访递,我是刑警寧澤晦嵌,帶...
    沈念sama閱讀 35,428評(píng)論 5 343
  • 正文 年R本政府宣布,位于F島的核電站拷姿,受9級(jí)特大地震影響惭载,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜响巢,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,022評(píng)論 3 326
  • 文/蒙蒙 一描滔、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧踪古,春花似錦含长、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,672評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至枕扫,卻和暖如春陪腌,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背烟瞧。 一陣腳步聲響...
    開封第一講書人閱讀 32,826評(píng)論 1 269
  • 我被黑心中介騙來泰國打工诗鸭, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人参滴。 一個(gè)月前我還...
    沈念sama閱讀 47,734評(píng)論 2 368
  • 正文 我出身青樓只泼,卻偏偏與公主長得像,于是被迫代替她去往敵國和親卵洗。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,619評(píng)論 2 354