<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
  .flex-container {
    display: flex;
	/*默认值:当一行放不下是就压缩子盒子*/
	/*flex-wrap: nowrap;*/
	
	/*当一行放不下时换行,第一行在上,其余行平分剩余空白*/
	flex-wrap: wrap;
	
	/*当一行放不下时换行,第一行在下,其余行平分剩余空白*/
	/*flex-wrap: wrap-reverse;*/
    width: 400px;
    height: 600px;
    background-color: gray;
  }

  .flex-item {
    background-color: green;
    width: 100px;
    height: 100px;
    margin: 5px;
  }
  </style>
</head>

<body>
  <div class="flex-container">
    <div class="flex-item">flex item 1</div>
    <div class="flex-item">flex item 2</div>
    <div class="flex-item">flex item 3</div>
    <div class="flex-item">flex item 4</div>
  </div>
</body>

</html>

flexbox父盒子flex-wrap属性

相关文章:

  • 2022-12-23
  • 2021-04-24
  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
  • 2021-05-03
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案