Blogger Information
Blog 21
fans 0
comment 0
visits 9407
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
flex布局模式:display:flex;
P粉116103988
Original
461 people have browsed it

flex的6大属性

效果图如下:


代码如下:

  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>flex布局</title>
  8. </head>
  9. <style>
  10. *{
  11. margin: 0;
  12. padding: 0;
  13. box-sizing: border-box;
  14. }
  15. .text{
  16. height: 20em;
  17. display: flex;
  18. /* flex-flow: 项目的主轴 于 换行 */
  19. /* 主轴不换行 */
  20. flex-flow: row nowrap;
  21. /* place-content: 项目在主轴上面的对齐方式; */
  22. /* 从头对齐 */
  23. place-content:start;
  24. /* 从末尾对齐 */
  25. place-content: end;
  26. /* 居中对齐 */
  27. place-content: center;
  28. /* 将剩余空间进行分配 */
  29. /* 向两端对齐 */
  30. place-content: space-between;
  31. /* 分散对齐 */
  32. place-content: space-around;
  33. /* 平均分配对齐 */
  34. place-content: space-evenly;
  35. /* place-items: 项目在Y轴的对齐方式; */
  36. /* 自动伸展 */
  37. place-items:stretch;
  38. /* 从上对齐 */
  39. place-items: start;
  40. /* 居中对齐 */
  41. place-items: center;
  42. /* 从下对齐 */
  43. place-items: end;
  44. }
  45. .text >.item{
  46. width: 10em;
  47. padding: 1em;
  48. border: 1px solid #000;
  49. background-color: lightpink;
  50. /* flex: 放大因子 收缩因子 计算宽度 */
  51. /* 默认 */
  52. flex: 0 1 auto;
  53. flex:initial;
  54. /* 可放大可缩小 */
  55. flex: 1 1 auto;
  56. flex: 1 auto;
  57. flex:auto;
  58. /* 禁止放大或缩小 */
  59. flex:none;
  60. flex:0 0 auto;
  61. }
  62. .text >.item:first-of-type{
  63. background-color: blue;
  64. order: 1;
  65. }
  66. .text >.item:last-of-type{
  67. background-color: yellow;
  68. order: -1;
  69. /* 控制某一个项目的对齐 */
  70. place-self: start;
  71. }
  72. </style>
  73. <body>
  74. <div class="text">
  75. <div class="item">item1</div>
  76. <div class="item">item2</div>
  77. <div class="item">item3</div>
  78. </div>
  79. </body>
  80. </html>
Correcting teacher:PHPzPHPz

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