5_弹性盒模型.html 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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>Document</title>
  8. <style>
  9. #div1{
  10. height: 500px;
  11. background: #ccc;
  12. display: flex;
  13. }
  14. #div2{
  15. width: 200px;
  16. height: 200px;
  17. background: #ff0000;
  18. }
  19. #div3{
  20. width: 200px;
  21. height: 200px;
  22. background: #000;
  23. flex: 2;
  24. }
  25. #div4{
  26. width: 200px;
  27. height: 200px;
  28. background: blue;
  29. flex: 1;
  30. }
  31. </style>
  32. </head>
  33. <body>
  34. <div id="div1">
  35. <div id="div2"></div>
  36. <div id="div3"></div>
  37. <div id="div4"></div>
  38. </div>
  39. <!--
  40. 弹性盒模型
  41. display: flex
  42. wrap 值规定 flex 项目将在必要时进行换行
  43. nowrap 值规定将不对 flex 项目换行(默认)
  44. wrap-reverse 值规定如有必要,弹性项目将以相反的顺序换行
  45. flex-direction 属性
  46. column 值设置垂直堆叠 flex 项目(从上到下)
  47. column-reverse 值垂直堆叠 flex 项目(但从下到上)
  48. row 值水平堆叠 flex 项目(从左到右)
  49. row-reverse 值水平堆叠 flex 项目(但从右到左)
  50. justify-content: flex-start|flex-end|center|space-between|space-around
  51. center 值将 flex 项目在容器的中心对齐
  52. flex-start 值将 flex 项目在容器的开头对齐(默认)
  53. flex-end 值将 flex 项目在容器的末端对齐
  54. space-around 值显示行之前、之间和之后带有空格的 flex 项目
  55. space-between 值显示行之间有空格的 flex 项目
  56. align-items:flex-start|flex-end|center|space-between|space-around
  57. space-between 值显示的弹性线之间有相等的间距
  58. space-around 值显示弹性线在其之前、之间和之后带有空格
  59. stretch 值拉伸弹性线以占据剩余空间(默认)
  60. center 值在容器中间显示弹性线
  61. flex-start 值在容器开头显示弹性线
  62. flex-end 值在容器的末尾显示弹性线
  63. -->
  64. </body>
  65. </html>