• 两栏布局和三栏布局的实现


    两栏布局

    左侧固定,右侧自适应,不给右侧设置固定宽度即可

    1.使用浮动float

    1     <div class="wrap">
    2         <div class="left">
    3             左侧固定内容
    4         </div>
    5         <div class="right">
    6             右侧内容自适应
    7         </div>
    8     </div>
     1     * {
     2         margin: 0;
     3         padding: 0;
     4     }
     5 
     6     .wrap {
     7         overflow: hidden;
     8         border: 1px solid red;
     9     }
    10 
    11     .left {
    12         float: left;
    13          200px;
    14         height: 200px;
    15         background: aqua;
    16     }
    17 
    18     .right {
    19         margin-left: 200px;
    20         background: aquamarine;
    21         height: 200px;
    22     }

    2.使用绝对定位absolute

    1     <div class="wrap">
    2         <div class="left">
    3             左侧固定内容
    4         </div>
    5         <div class="right">
    6             右侧内容自适应
    7         </div>
    8     </div>
     1     * {
     2         margin: 0;
     3         padding: 0;
     4     }
     5 
     6     .wrap {
     7         overflow: hidden;
     8         position: relative;
     9     }
    10 
    11     .left {
    12         position: absolute;
    13         left: 0;
    14         top: 0;
    15          200px;
    16         height: 200px;
    17         background: aqua;
    18     }
    19 
    20     .right {
    21         margin-left: 200px;
    22         background: aquamarine;
    23         height: 220px;
    24     }

    3.使用弹性布局flex

    1     <div class="wrap">
    2         <div class="left">
    3             左侧固定内容
    4         </div>
    5         <div class="right">
    6             右侧内容自适应
    7         </div>
    8     </div>
     1     * {
     2         margin: 0;
     3         padding: 0;
     4     }
     5 
     6     .wrap {
     7         display: flex;
     8     }
     9 
    10     .left {
    11          200px;
    12         height: 200px;
    13         background: aqua;
    14     }
    15 
    16     .right {
    17         background: aquamarine;
    18         height: 200px;
    19         flex: 1;
    20     }

    4.使用表格布局table 

    1     <div class="wrap">
    2         <div class="left">
    3             左侧固定内容
    4         </div>
    5         <div class="right">
    6             右侧内容自适应
    7         </div>
    8     </div>
     1     * {
     2         margin: 0;
     3         padding: 0;
     4     }
     5 
     6     .wrap {
     7         display: table;
     8          100%;
     9     }
    10 
    11     .left {
    12         display: table-cell;
    13          200px;
    14         height: 200px;
    15         background: aqua;
    16     }
    17 
    18     .right {
    19         display: table-cell;
    20         background: aquamarine;
    21         height: 200px;
    22     }

    三栏布局

  • 相关阅读:
    C#高级特性_Attribute
    C#高级特性_Lambda
    委托(delegate)
    C# 属性、索引
    C#中的interface
    枚举型Enum和结构型Stuct
    javascript学习笔记
    github page 和 hexo 搭建在线博客
    2015/9/22 开通博客园
    phoenix 入门
  • 原文地址:https://www.cnblogs.com/memeflyfly/p/14305107.html
Copyright © 2020-2023  润新知