ASCII码 ASCII码

Gird布局实战(圣杯布局)

发布于:2022-05-28 15:48:33  栏目:技术文档

  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>Gird布局实战(圣杯布局)</title>
  8. </head>
  9. <body>
  10. <header>页眉</header>
  11. <aside>左侧</aside>
  12. <main>主体</main>
  13. <aside>右侧</aside>
  14. <footer>页脚</footer>
  15. <style>
  16. *{
  17. padding:0;
  18. margin:0;
  19. box-sizing: border-box;
  20. }
  21. body *{
  22. background-color: lightgreen;
  23. }
  24. body {
  25. display: grid;
  26. /* 3行3列 */
  27. /* minmax(400px,1fr) 中间响应式,两边固定 */
  28. grid-template-columns: 200px minmax(400px,1fr) 200px;
  29. /* minmax(clac(100vh - 6em - 0.6em),1fr) */
  30. grid-template-rows: 3em minmax(calc(100vh - 6em - 0.6em),1fr) 3em;
  31. gap: 0.3em;
  32. place-content: center;
  33. }
  34. header,
  35. footer{
  36. grid-column: span 3;
  37. }
  38. </style>
  39. </body>
  40. </html>
相关推荐
阅读 +