我的网站开发技术经验总结 我的网站开发技术经验总结
首页

fangdown

我的网站开发技术经验总结
首页
  • 大前端

  • 基础

    • js

    • css

      • 如何让chrome实现小于12px的字体大小
      • 如何使用css画出三角形,正方形
      • 如何使用CSS完成视差滚动效果
      • 说说单行和多行文本溢出的实现方式
      • 说说对Css预编语言的理解
      • 说说你对CSS盒子模型的理解
      • 说说设备像素、css像素、设备独立像素、dpr、ppi 之间的区别
      • 说说什么是响应式设计及实现方式
      • 说说什么是重绘和回流,如何优化
      • 说说元素水平垂直居中的方法有哪些
      • 说说CSS3新增了哪些新特性
      • 说说css性能优化有哪些方式
      • 说说css中层叠上下文z-index的理解
      • 说说css中的选择器是优先级
      • 说说css中两栏布局和三栏布局有哪些
        • 是什么
        • 两栏布局
          • 浮动布局
          • flex布局
        • 三栏布局
          • flex布局 (grid类似)
          • float + margin
          • 两边定位absolute 中间margin
          • table布局(不适用)
      • 说说css中哪些属性是继承和不继承的
      • 说说css中实现动画有哪些
      • 说说CSS中有哪些方式可以隐藏页面元素
      • 说说em-px-rem-vh-vw的区别
      • 说说flex盒子的理解及应用
      • 说说property和prototype的区别
      • 谈谈你对BFC的理解
    • ES6

  • 框架

  • 情商

  • 算法

  • 网络

  • 千锤百炼
  • 基础
  • css
fangdown
2021-08-20
目录

说说css中两栏布局和三栏布局有哪些

# 是什么

在日常布局中,无论是两栏布局还是三栏布局,使用的频率都非常高

# 两栏布局

  • 特性: 左边固定,右边自适应

比如很多后台管理系统,antd等

# 浮动布局

  <style>
    .box{overflow: hidden;}
    .left{
      float: left;
      width: 200px;
      height: 200px;
      background-color: green;
    }
    .right{
      margin-left: 200px;
      height: 300px;
      background-color: #eee;
    }
  </style>
  <div class="box">
    <div class="left"></div>
    <div class="right"></div>
  </div>

# flex布局

  <style>
    .box2{
      display: flex;
    }
    .left2{
      width: 200px;
      background-color: green;
    }
    .right2{
      flex: 1;
      background-color: #eee;
    }
  </style>
  <div class="box2">
    <div class="left2"></div>
    <div class="right2"></div>
  </div>

# 三栏布局

  • 特性: 两边固定,中间自适应

比如github

# flex布局 (grid类似)

  <style>
    .left,
    .right,
    .middle {
        height: 100px;
    }
    .box1{
      display: flex;
    }
    .box1 .left{
      width: 200px;
      background-color: green;
    }
    .box1 .middle{
      flex: 1;
      background-color:azure
    }
    .box1 .right{
      width: 200px;
      background-color:burlywood;
    }
  </style>
  <div class="box1">
    <div class="left"></div>
    <div class="middle"></div>
    <div class="right"></div>
  </div>

# float + margin

<style>
  .box2{
    overflow: hidden;
  }
  .box2 .left{
    width: 200px;
    float: left;
    background-color: green;
  }
  .box2 .middle{
    width: 100%;
    background-color:azure;
    margin:0 200px 0 200px;
  }
  .box2 .right{
    width: 200px;
    float: right;
    background-color:burlywood;
  }
</style>
<div class="box2">
  <div class="left"></div>
  <div class="right"></div>
  <div class="middle"></div>
</div>

# 两边定位absolute 中间margin

<style>
  .box3{
    overflow: hidden;
    display:table;
  }
  .box3 .left{
    width: 200px;
    background-color: green;
    position: absolute;
    left: 0;
    top: 0;
  }
  .box3 .middle{
    width: 100%;
    background-color:azure;
    margin:0 200px;
  }
  .box3 .right{
    width: 200px;
    background-color:burlywood;
    position: absolute;
    right: 0;
    top: 0;
  }
</style>
<div class="box3">
  <div class="left"></div>
  <div class="middle"></div>
  <div class="right"></div>
</div>

# table布局(不适用)

<style>
  .box4{
    overflow: hidden;
    /* display: table; */
  }
  .box4 .left{
    width: 200px;
    background-color: green;
    display: table-cell;
  }
  .box4 .middle{
    width: 500px;
    background-color:azure;
    display: table-cell;
  }
  .box4 .right{
    width: 200px;
    background-color:burlywood;
    display: table-cell;
  }
</style>
<div class="box4">
  <div class="left"></div>
  <div class="middle"></div>
  <div class="right"></div>
</div>
#布局
上次更新: 2021/12/19, 18:05:42
说说css中的选择器是优先级
说说css中哪些属性是继承和不继承的

← 说说css中的选择器是优先级 说说css中哪些属性是继承和不继承的→

最近更新
01
多分支修复撞车的问题
05-01
02
如何成为架构师
01-23
03
服务器部署全过程
11-23
更多文章>
Theme by Vdoing | Copyright © 2019-2026 fangdown | 粤ICP备19079809号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式