HTML

/*适用方法1,方法2*/
<body>
  <div class="container">
  <div class="left"></div>
  <div class="middle"></div>
  <div class="right"></div>
  </div>
</body>

/* 适用方法3:*/
<body>
  <div class="container">
  <div class="left"></div>
  <div class="right"></div>
  <div class="middle"></div>
  </div>
</body>

CSS

/*方法1:定位实现*/
.container {
position: relative;
}
.left {
position: absolute;
left: 0;
top: 0;
width: 200px;
height: 100px;
background-color: red;
}
.middle {
box-sizing: border-box;
width: 100%;
height: 100px;
padding-left: 200px;
padding-right: 200px;
background-color: blue;
}
.right {
position: absolute;
top: 0;
right: 0;
width: 200px;
height: 100px;
background-color: red;
}
/*方法2:弹性布局实现*/
.container {
display: flex;
}
.left {
flex: 0 0 200px;
height: 100px;
background-color: red;
}
.middle {
width: 100%;
height: 100px;
background-color: blue;
}
.right {
flex: 0 0 200px;
height: 100px;
background-color: red;
}
/*方法3:浮动实现*/
.container {
overflow: hidden;
}
.left {
float: left;
width: 200px;
height: 100px;
background-color: red;
}
.middle {
box-sizing: border-box;
width: 100%;
height: 100px;
padding-left: 200px;
padding-right: 200px;
background-color: blue;
}
.right {
float: right;
width: 200px;
height: 100px;
background-color: red;
}

相关文章:

  • 2022-02-06
  • 2021-06-18
  • 2022-01-06
  • 2021-10-07
  • 2022-12-23
猜你喜欢
  • 2021-04-22
  • 2022-01-04
  • 2022-12-23
  • 2021-07-08
  • 2021-12-16
  • 2022-12-23
  • 2021-07-21
相关资源
相似解决方案