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

更多相关文章

  1. flex项目属性,实战案例。
  2. CSS:选择器优先级、前端组件样式模块化原理实现、常用伪类选择器
  3. flex容器中的四个属性的功能演示
  4. flex容器属性的功能,参数,以及作用
  5. css-flex布局
  6. 3.24实例演示flex容器中的四个属性的功能,参数,以及作用
  7. 0324作业-flex布局
  8. Python合并字典的七种方式!
  9. Google Guice之注入方式

随机推荐

  1. RelativeLayout常用属性
  2. Android 调试:java 跨工程调试 android 项
  3. textview 小结
  4. android计算器布局界面——基础编
  5. Android 的manager
  6. Android Architecture
  7. Android中各种ontouch事件
  8. Android(安卓)利用addView 动态给Activit
  9. Android ADB=Android Debug Bridge帮助信
  10. Android 自定义控件打造史上最简单的侧滑