6.案例2.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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>Document</title>
  7. <style>
  8. * {
  9. margin: 0;
  10. padding: 0;
  11. }
  12. h3 {
  13. width: 100%;
  14. height: 50px;
  15. font-size: 24px;
  16. font-weight: bold;
  17. line-height: 50px;
  18. text-align: center;
  19. background: #ccc;
  20. margin-bottom: 10px;
  21. }
  22. #imgBox {
  23. width: 100%;
  24. height: 300px;
  25. background: url('./images/3.jpg') no-repeat;
  26. background-position: center;
  27. }
  28. #main {
  29. width: 100%;
  30. margin: 10px auto;
  31. }
  32. .sideBar {
  33. width: 100%;
  34. height: 200px;
  35. background: #0f0;
  36. }
  37. .container {
  38. width: 100%;
  39. height: 200px;
  40. background: plum;
  41. }
  42. @media screen and (min-width:480px) {
  43. #imgBox {
  44. width: 100%;
  45. height: 500px;
  46. background: url('./images/1.jpg') no-repeat;
  47. background-position: center;
  48. }
  49. #main {
  50. width: 100%;
  51. margin: 10px auto;
  52. overflow: hidden;
  53. }
  54. .sideBar {
  55. width: 65vw;
  56. height: 200px;
  57. background: #0f0;
  58. float: left;
  59. }
  60. .container {
  61. width: 30vw;
  62. height: 200px;
  63. background: plum;
  64. float: right;
  65. }
  66. }
  67. @media screen and (min-width:960px) {
  68. #imgBox {
  69. width: 100%;
  70. height: 600px;
  71. background: url('./images/2.jpg') no-repeat;
  72. background-position: center;
  73. background-size: cover;
  74. }
  75. #main {
  76. width: 100%;
  77. margin: 25px auto;
  78. overflow: hidden;
  79. }
  80. .sideBar {
  81. width: 65vw;
  82. height: 200px;
  83. background: #ff0;
  84. float: left;
  85. }
  86. .container {
  87. width: 30vw;
  88. height: 200px;
  89. background: plum;
  90. float: right;
  91. }
  92. }
  93. </style>
  94. </head>
  95. <body>
  96. <h3>页眉</h3>
  97. <h3>导航</h3>
  98. <div id="imgBox"></div>
  99. <div id="main">
  100. <div class="sideBar"></div>
  101. <div class="container"></div>
  102. </div>
  103. <h3>页尾</h3>
  104. </body>
  105. </html>