flexbox父盒子flex-wrap屬性


<!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>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM