三列布局(两列定宽,一列自适应)

2019-10-17  本文已影响0人  蜗牛和曼巴
方法一:float+overflow
  <div class="box">
    <div class="class1">1</div>
    <div class="class2">2</div>
    <div class="class3">3</div>
  </div>
<style>
  .class1{
    width: 100px;
    height: 400px;
    background: red;
    float: left;
  }
  .class2{
    width: 100px;
    height: 400px;
    background: rgb(25, 0, 255);
    float: left;
  }
  .class3{
    height: 400px;
    background: rgb(233, 199, 10);
    overflow: hidden;
  }
</style>
方法二:flex
  <div class="box">
    <div class="class1">1</div>
    <div class="class2">2</div>
    <div class="class3">3</div>
  </div>
<style>
  .box{
    display: flex;
  }
  .class1{
    width: 100px;
    height: 400px;
    background: red;
  }
  .class2{
    width: 100px;
    height: 400px;
    background: rgb(25, 0, 255);
  }
  .class3{
    height: 400px;
    background: rgb(233, 199, 10);
    flex: 1
  }
</style>
上一篇 下一篇

猜你喜欢

热点阅读