日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > CSS >内容正文

CSS

CSS多列布局(实例)

發布時間:2023/12/2 CSS 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CSS多列布局(实例) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

前言

  • 一列布局
  • 二列布局
  • 三列布局
  • ?

    1 一列布局

    • 一列布局: HTML部分 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>一列布局</title> </head> <body> <div class="head">head</div> <div class="main">main</div> <div class="foot">foot</div> </body> </html>CSS部分 div{text-align: center;} .head{height: 60px;background-color:#fae1e1;} .main{margin: 0 auto;height:300px;background-color:#e6686a;} .foot{margin: 0 auto;background-color:red;}

      ?

    • 效果圖如下:

    ?

    2 二列布局

    • 二列布局代碼如下(即左右布局),二列布局有多種方法,float margin(一側定寬,一側自動)、position margin(一側定寬,一側自動)、float 負margin(一側定寬,一側自動)等,本篇用的是設定兩欄的寬度的百分比,隨寬度自適應變化代碼如下: HTML部分 <!DOCTYPE html> <html> <head> <title>二列布局</title> </head> <body> <div class="main"> <div class="left">left</div> <div class="right">right</div> </div> </body> </htmlCSS部分 body{ margin:0; padding:0; font-size:20px; font-weight:bold} div{ text-align:center; line-height:50px} .main{ width:80%; height:400px; margin:0 auto} .left{ width:20%; height:400px; background:#e6686a; float:left} .right{ width:80%; height:400px; background:#fae1e1; float:right}

      ?

    • 效果圖如下:

    ?

    3 三列布局

    • 三列布局(即左中右布局),三列布局有多種方法,float margin(兩側定寬,中間自適應)、position margin(兩側定寬,中間自適應)、float 負margin(兩側定寬,中間自適應)、float position margin(兩側自動,中間定寬)、position margin(兩側自動,中間定寬),本篇用的是float margin(兩側定寬,中間自適應),代碼如下:
      HTML部分 <!DOCTYPE html> <html> <head><meta charset="utf-8"><title>JS Bin</title> </head> <body> <div class="left">left</div> <div class="center">main</div> <div class="right">right</div> </body> </html>CSS部分 body{ margin:0; padding:0; font-weight:bold} div{ line-height:40px} .left{height:400px; width:200px; position: absolute; left:0; top:0;background:#fae1e1;} .right{ height:400px; width:200px; position:absolute; top:0;right:0;; background:#fae1e1} .center{ height:400px; margin:0 200px; background:#e6686a}

      ?

    • 效果圖如下:

    總結

    以上是生活随笔為你收集整理的CSS多列布局(实例)的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。