5.案例.html 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. header, nav, footer {
  9. width: 100%;
  10. height: 80px;
  11. font-size: 24px;
  12. font-weight: bold;
  13. text-align: center;
  14. line-height: 80px;
  15. background: #ccc;
  16. margin-top: 10px;
  17. }
  18. .part1 {
  19. width: 100%;
  20. height: 150px;
  21. background: #f00;
  22. }
  23. .part2 {
  24. width: 100%;
  25. height: 150px;
  26. background: #00f;
  27. }
  28. @media screen and (max-width: 758px) {
  29. .picture {
  30. width: 100%;
  31. height: 300px;
  32. background: url("./images/3.jpg") no-repeat center center;
  33. }
  34. }
  35. @media screen and (min-width:768px) and (max-width: 1000px) {
  36. .picture {
  37. width: 100%;
  38. height: 500px;
  39. background: url("./images/1.jpg") no-repeat center center;
  40. margin-top: 10px;
  41. }
  42. .main {
  43. display: flex;
  44. }
  45. .part1 {
  46. flex: 3;
  47. }
  48. .part2 {
  49. flex: 2;
  50. margin-left: 15px;
  51. }
  52. }
  53. @media screen and (min-width: 1001px) {
  54. .picture {
  55. width: 100%;
  56. height: 500px;
  57. background: url("./images/2.jpg") no-repeat center center;
  58. }
  59. }
  60. </style>
  61. </head>
  62. <body>
  63. <div>
  64. <header>页眉</header>
  65. <nav>导航</nav>
  66. <div class="picture"></div>
  67. <div class="main">
  68. <div class="part1"></div>
  69. <div class="part2"></div>
  70. </div>
  71. <footer>页尾</footer>
  72. </div>
  73. </body>
  74. </html>