03-主轴对齐方式.html 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>主轴对齐方式</title>
  8. <style>
  9. * {
  10. margin: 0;
  11. padding: 0;
  12. }
  13. .box {
  14. display: flex;
  15. /* 居中 */
  16. justify-content: center;
  17. /* 间距在弹性盒子(子级)之间 */
  18. justify-content: space-between;
  19. /* 所有地方的间距都相等 */
  20. justify-content: space-evenly;
  21. /* 间距加在子级的两侧 */
  22. /* 视觉效果: 子级之间的距离是父级两头距离的2倍 */
  23. justify-content: space-around;
  24. height: 200px;
  25. margin: auto;
  26. border: 1px solid #000;
  27. }
  28. .box div {
  29. width: 100px;
  30. height: 100px;
  31. background-color: pink;
  32. }
  33. </style>
  34. </head>
  35. <body>
  36. <div class="box">
  37. <div>1</div>
  38. <div>2</div>
  39. <div>3</div>
  40. </div>
  41. </body>
  42. </html>