博客列表 >flex制作三列布局

flex制作三列布局

Brain
Brain原创
2020年08月15日 12:12:121124浏览
  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 homework</title>
  7. <style>
  8. * {
  9. margin: 0;
  10. padding: 0;
  11. box-sizing: border-box;
  12. }
  13. body {
  14. width: 90vw;
  15. height: 100vh;
  16. margin: 0 auto;
  17. }
  18. .container {
  19. display: flex;
  20. outline: 1px solid red;
  21. flex-flow: row wrap;
  22. justify-content: space-between;
  23. align-content: space-between;
  24. height: 100vh;
  25. }
  26. .container > .item:first-of-type,
  27. .item:last-of-type {
  28. flex: 0 0 90vw;
  29. background-color: lightcyan;
  30. height: 10vh;
  31. min-height: 80px;
  32. }
  33. .container > .item2,
  34. item3,
  35. item4 {
  36. height: 80vh;
  37. min-height: 400px;
  38. }
  39. .container > .item2,
  40. .item4 {
  41. flex: 0 0 20vw;
  42. background-color: lightyellow;
  43. }
  44. .container > .item2 {
  45. justify-content: flex-start;
  46. }
  47. .container > .item4 {
  48. justify-content: flex-end;
  49. }
  50. .container > .item3 {
  51. flex: 1 1 auto;
  52. background-color: lightred;
  53. }
  54. </style>
  55. </head>
  56. <body>
  57. <div class="container">
  58. <div class="item item1">弹性盒子布局header</div>
  59. <div class="item item2">left</div>
  60. <div class="item item3">main</div>
  61. <div class="item item4">right</div>
  62. <div class="item item5">footer</div>
  63. </div>
  64. </body>
  65. </html>
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议