欧美videos另类精品-欧美videos另类极品-欧美vide-欧美va在线视频-欧美va在线观看-欧美va在线播放免费观看

兩欄布局

2019-11-29    seo達人

兩列布局的幾種方法

html結構

 <div class="content">

      <div class="content-left">

        左側固定200px

      </div>

      <div class="content-right">

        右側自適應

      </div>

 </div>



1.通過float和margin-left

 / 清除瀏覽器默認邊距 /

      {

        margin: 0;

        padding: 0;

      }



      .content{

        overflow: hidden;

      }

      /
脫離文檔流 /

      .content-left {

        float: left;

        width: 200px;

        height: 200px;

        background: red;

      }



      .content-right {

        /
通過margin-left將左邊位置空出 /

        margin-left: 200px;

        background: blue;

        height: 200px;

      }



2.通過 position: absolute;絕對定位

 /
清除瀏覽器默認邊距 /

     
{

        margin: 0;

        padding: 0;

      }



      .content {

        overflow: hidden;

        position: relative;

      }

      / 脫離文檔流 /

      .content-left {

        position: absolute;

        top: 0;

        left: 0;

        width: 200px;

        height: 200px;

        background: red;

      }



      .content-right {

        / 通過margin-left將左邊位置空出 /

        margin-left: 200px;

        background: blue;

        height: 200px;

      }



3.通過flex彈性布局

/ 清除瀏覽器默認邊距 /

      {

        margin: 0;

        padding: 0;

      }



      .content {

        overflow: hidden;

        display: flex;

      }

      .content-left {

          /
除了width: 200px;還可以flex-basis: 200px; /

        width: 200px;

        height: 200px;

        background: red;

      }



      .content-right {

          /
flex:1;將剩余空間分給它 /

        flex: 1;

        background: blue;

        height: 200px;

      }



4.通過 display: table;表格布局

 /
清除瀏覽器默認邊距 /

     
{

        margin: 0;

        padding: 0;

      }



      .content {

        overflow: hidden;

        display: table;

        / 必須給父級定寬不然自適應盒子沒定寬只會由內容撐開 /

        width: 100%;

      }

      .content-left {

        display: table-cell;

        width: 200px;

        height: 200px;

        background: red;

      }



      .content-right {

        display: table-cell;

        background: blue;

        height: 200px;

      }



5.通過inline-block和calc()函數

 / 清除瀏覽器默認邊距 /

      {

        margin: 0;

        padding: 0;

      }



      .content {

        /
必須加font-size=0;把inline-block默認間距去掉,

        不過設置后里面文字不顯示了可以給里面塊設置font-size:20px;

        或者把兩個塊之間的換行刪掉也能去掉間距/

        font-size: 0;

        overflow: hidden;

      }

      .content-left {

        font-size: 20px;

        display: inline-block;

        width: 200px;

        height: 200px;

        background: red;

      }



      .content-right {

        font-size: 20px;

        display: inline-block;

        background: blue;

        height: 200px;

        /
注意calc里的運算符兩邊要有空格 /

        width: calc(100% - 200px);

      }



6.通過float和calc()函數,左右兩塊都要浮動

 /
清除瀏覽器默認邊距 /

     
{

        margin: 0;

        padding: 0;

      }



      .content {

        overflow: hidden;

      }

      .content-left {

        float: left;

        width: 200px;

        height: 200px;

        background: red;

      }

      .content-right {

        float: left;

        background: blue;

        height: 200px;

        / 注意calc里的運算符兩邊要有空格 /

        width: calc(100% - 200px);

      }



7.使用grid布局

 / 清除瀏覽器默認邊距 /

      {

        margin: 0;

        padding: 0;

      }



      .content {

        overflow: hidden;

        display: grid;

        grid-template-columns: 200px 1fr;

        /
grid布局也有列等高的默認效果。需要設置: align-items: start;。 /

        align-items: start;

      }

      .content-left {

        height: 200px;

        background: red;

        /
grid布局還有一個值得注意的小地方和flex不同:在使用margin-left的時候,

        grid布局默認是box-sizing設置的盒寬度之間的位置。

        而flex則是使用兩個div的border或者padding外側之間的距離。 */

        box-sizing: border-box;

        grid-column: 1;

      }

      .content-right {

        background: blue;

        height: 200px;

        box-sizing: border-box;

        grid-column: 2;

      }



日歷

鏈接

個人資料

藍藍設計的小編 http://m.73404.com.cn

存檔

主站蜘蛛池模板: 91短视频在线观看2019 | 极端 成熟 性别 视频 | 欧美一区a| 免费观看视频在线 | 日韩在线 中文字幕 | 日韩福利一区 | 我半夜摸妺妺的奶C了她软件 | 国内剧情麻豆 | 91久久综合九色综合欧美98 | 精品国产日韩亚洲一区在线 | 4虎影视国产在线观看精品 4s4s4s4s色大众影视 | 二次元美女扒开内裤露尿口 | 精品老司机在线视频香蕉 | 亚洲AV精品一区二区三区不卡 | www视频免费 | 无码中文字幕av免费放 | 亚洲性夜 | 60岁了天天要小伙子 | 91在线永久 | 亚洲 日韩 国产 中文视频 | 国产成人久久久精品一区二区三区 | 午夜DY888国产精品影院 | 国内视频一区二区三区 | sxx免费看观看美女 sss亚洲国产欧美一区二区 | 四虎影院免费视频 | 果冻传媒在线视频播放观看 | 国产精品久久久久久久久免费 | 天天狠天天透天干天天怕处 | 午夜福利体检 | 免费的毛片视频 | xxxx野外性xxxx| 国产精品日韩在线观看 | 亚洲精品国产自在现线最新 | 92在线视频 | 久久久久久久尹人综合网亚洲 | 色猪视频 | 久草在线精彩免费视频 | 精品午夜久久福利大片免费 | 国色天香社区在线视频免费观看 | 日韩欧美亚洲天堂 | 波多野结衣女教师在线观看 |