You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1016 B

2 years ago
  1. <html lang="en">
  2. <head>
  3. <meta charset="UTF-8">
  4. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. <style>
  8. /* 如果父元素的宽度不够子元素宽度的总和,子元素会被压缩,以便子元素充分的显示 */
  9. #div0 {
  10. width: 300px;
  11. background-color: blue;
  12. display: flex;
  13. /* 设置 flex 布局的方向 */
  14. /* flex-direction: row; */
  15. /* 设置 flex 的换行效果 */
  16. /* flex-wrap: wrap; */
  17. /* flex-flow 是 flex-direction 和 flex-wrap 的简写*/
  18. flex-flow: row wrap;
  19. }
  20. #div0 div {
  21. width: 100px;
  22. height: 100px;
  23. background-color: aqua;
  24. }
  25. </style>
  26. </head>
  27. <body>
  28. <div id="div0">
  29. <div>1</div>
  30. <div>2</div>
  31. <div>3</div>
  32. <div>4</div>
  33. </div>
  34. </body>
  35. </html>