Blogger Information
Blog 11
fans 0
comment 0
visits 9072
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
flex容器常用的四个属性
酿酒的人ァ
Original
523 people have browsed it
  • flex-flow: 设置主轴的方向和项目在主轴的换行方式
  • justify-content: 项目在主轴的对齐方式
  • align-items: 项目在交叉轴上的对齐方式
  • align-content: 设置项目在多行容器中的对齐方式

代码实例:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>实例演示:flex容器常用的四个属性</title>
  7. <style>
  8. * {
  9. box-sizing: border-box;
  10. }
  11. .container {
  12. height: 15em;
  13. border: 1px solid coral;
  14. padding: 1em;
  15. margin: 1em;
  16. display: flex;
  17. }
  18. .container > .item {
  19. width: 8em;
  20. background-color: lightyellow;
  21. border: 1px solid chocolate;
  22. }
  23. .container {
  24. flex-flow: row nowrap;
  25. flex-flow: row wrap;
  26. }
  27. /* .container {
  28. flex-flow: column nowrap;
  29. flex-flow: column wrap;
  30. flex-flow: column wrap-reverse;
  31. height: 8em;
  32. } */
  33. .container {
  34. justify-content: flex-start;
  35. justify-content: flex-end;
  36. justify-content: flex-end;
  37. justify-content: center;
  38. justify-content: space-between;
  39. justify-content: space-around;
  40. justify-content: space-evenly;
  41. }
  42. .container {
  43. flex-flow: row nowrap;
  44. align-items: stretch;
  45. align-items: flex-start;
  46. align-items: flex-end;
  47. align-items: center;
  48. }
  49. /.container {
  50. flex-flow: row wrap;
  51. align-content: stretch;
  52. align-content: flex-end;
  53. align-content: flex-start;
  54. align-content: center;
  55. align-content: space-around;
  56. align-content: space-between;
  57. align-content: space-evenly;
  58. }
  59. </style>
  60. </head>
  61. <body>
  62. <div class="container">
  63. <div class="item">item1</div>
  64. <div class="item">item2</div>
  65. <div class="item">item3</div>
  66. <div class="item">item4</div>
  67. <div class="item">item5</div>
  68. <div class="item">item6</div>
  69. <div class="item">item7</div>
  70. <div class="item">item8</div>
  71. </div>
  72. </body>
  73. </html>
Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post