美文网首页
面试题 -- 实现左自适应,右固定宽度的布局

面试题 -- 实现左自适应,右固定宽度的布局

作者: 开着五菱宏光的小白 | 来源:发表于2019-04-22 12:46 被阅读0次

    html 代码

      <div class="wraper">
            <div class="left"></div>
            <div class="right"></div>
        </div>
    
    

    第一种使用table、table-cell

     .wraper {
            display: table;
            width: 200px;
        }
        .left {
            display: table-cell;
            width: 5000px;
            background-color: green;
        }
        .right {
            background-color: yellow;
            width: 100px;
            height: 150px
        }
    
    

    第二种使用flex布局

    .wraper {
            width: 200px;
            height: 200px;
            border: 1px solid solid;
            display: flex;
            background-color: blue;
        }
        .left {
            height: 150px;
            background-color: green;
            flex: 1;
        }
        .right {
            background-color: yellow;
            width: 100px;
            height: 150px;
            float: right;
        }
    
    

    第三种使用float和margin
    html代码

        <div class="wraper">
            <div class="right"></div>
            <div class="left"></div>
        </div>
    
      .wraper {
            width: 400px;
        }
        .left {
            margin-right: 200px;
            height: 100px;
            background-color: blue;
        }
        .right {
            float: right;
            width: 200px;
            height: 100px;
            background-color: green;
        }
    
    

    相关文章

      网友评论

          本文标题:面试题 -- 实现左自适应,右固定宽度的布局

          本文链接:https://www.haomeiwen.com/subject/nrujgqtx.html