02.网页的布局练习.html 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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>网页的布局</title>
  8. <style>
  9. /* 分组,设置共同样式,减少代码量 */
  10. header,main,footer{
  11. width: 1000px;
  12. margin: 0 auto;
  13. }
  14. nav,article,aside{
  15. float: left;
  16. height: 100%;
  17. }
  18. /* 是总头部 */
  19. header{
  20. height: 150px;
  21. background-color: silver;
  22. }
  23. /* 设置主体 */
  24. main{
  25. height: 400px;
  26. background-color: #bfa;
  27. margin: 10px auto;
  28. }
  29. /* 设置左侧的导航 */
  30. nav{
  31. width: 200px;
  32. background-color: yellow;
  33. }
  34. article{
  35. width: 580px;
  36. background-color: orange;
  37. margin: 0 10px;
  38. }
  39. aside{
  40. width: 200px;
  41. background-color: pink;
  42. }
  43. /* 设置底部 */
  44. footer{
  45. height: 150px;
  46. background-color: tomato;
  47. }
  48. </style>
  49. </head>
  50. <body>
  51. <!-- 创建头部 -->
  52. <header></header>
  53. <!-- 创建网页的主体 -->
  54. <main>
  55. <!-- 左侧导航 -->
  56. <nav></nav>
  57. <!-- 中间的内容 -->
  58. <article></article>
  59. <!-- 右边的边栏 -->
  60. <aside></aside>
  61. </main>
  62. <!-- 创建网页的底部 -->
  63. <footer></footer>
  64. </body>
  65. </html>