Blogger Information
Blog 40
fans 0
comment 1
visits 24387
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
第10章 1222-flex元素常用属性详解,学习心得、笔记
努力工作--周工--Robin
Original
504 people have browsed it

今天所学心得、笔记

1、将flex容器与项目的常用属性全部进行实例演示;

示例代码,CSS部分

  1. <style>
  2. .container {
  3. min-height: 10em;
  4. border: solid 1px;
  5. }
  6. .item {
  7. font-size: 2em;
  8. font-weight: bold;
  9. text-align: center;
  10. width: 3em;
  11. background-color: violet;
  12. border: solid 1px;
  13. }
  14. .container {
  15. display: flex;
  16. /*水平排列,反顺序*/
  17. flex-direction: row-reverse;
  18. /*垂直排列*/
  19. flex-direction: column;
  20. /*垂直排列,反顺序*/
  21. flex-direction: column-reverse;
  22. /*水平排列,允许换行*/
  23. flex-flow: wrap;
  24. /*水平排列,元素紧贴左边*/
  25. justify-content: flex-start;
  26. /*水平排列,元素紧贴右边*/
  27. justify-content: flex-end;
  28. /*水平排列,剩余空间在元素中间平分,最左右两边无空间*/
  29. justify-content: space-between;
  30. /*水平排列,剩余空间在元素两边平分,最左右两边有空间*/
  31. justify-content: space-around;
  32. /*水平排列,剩余空间以元素数量平分,最左右两边有空间*/
  33. justify-content: space-evenly;
  34. /*垂直排列,元素置顶*/
  35. align-items: flex-start;
  36. /*垂直排列,元素置底*/
  37. align-items: flex-end;
  38. /*垂直排列,元素居中*/
  39. align-items: center;
  40. /*垂直排列,元素拉伸*/
  41. align-items: stretch;
  42. }
  43. .container .item:nth-of-type(1) {
  44. /*垂直排列,该元素置顶*/
  45. align-self: flex-start;
  46. /*1号元素,布置在最后,第4*/
  47. order: 10;
  48. /*1号元素最总容器的 10%*/
  49. flex: 1;
  50. }
  51. .container .item:nth-of-type(2) {
  52. /*垂直排列,该元素居中*/
  53. align-self: center;
  54. /*2号元素,倒数第2,第4*/
  55. order: 8;
  56. flex: 2;
  57. }
  58. .container .item:nth-of-type(3) {
  59. /*垂直排列,该元素置底部*/
  60. align-self: flex-end;
  61. /*3号元素,布置在第2*/
  62. order: 6;
  63. /*3号元素最总容器的 30%*/
  64. flex: 3;
  65. }
  66. .container .item:nth-of-type(4) {
  67. /*垂直排列,该元素拉伸*/
  68. align-self: stretch;
  69. /*4号元素,布置在第1*/
  70. order: 3;
  71. /*4号元素最总容器的 40%*/
  72. flex: 4;
  73. }
  74. </style>

示例代码,HTML部分

  1. <div class="container">
  2. <div class="item">1</div>
  3. <div class="item">2</div>
  4. <div class="item">3</div>
  5. <div class="item">4</div>
  6. <!-- <div class="item">5</div>-->
  7. <!-- <div class="item">6</div>-->
  8. <!-- <div class="item">7</div>-->
  9. <!-- <div class="item">8</div>-->
  10. <!-- <div class="item">9</div>-->
  11. <!-- <div class="item">10</div>-->
  12. </div>

示例代码截图部

















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