demo1.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Swiper demo</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
  7. <!-- Link Swiper's CSS -->
  8. <link rel="stylesheet" href="./dist/css/swiper.min.css">
  9. <!-- Demo styles -->
  10. <style>
  11. html,
  12. body {
  13. position: relative;
  14. height: 100%;
  15. }
  16. body {
  17. background: #fff;
  18. font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
  19. font-size: 14px;
  20. color: #000;
  21. margin: 0;
  22. padding: 0;
  23. }
  24. .swiper-container {
  25. width: 300px;
  26. height: 300px;
  27. position: absolute;
  28. left: 50%;
  29. top: 50%;
  30. margin-left: -150px;
  31. margin-top: -150px;
  32. }
  33. .swiper-slide {
  34. background-position: center;
  35. background-size: cover;
  36. }
  37. .logo {
  38. display: flex;
  39. justify-content: start;
  40. background: #589fc3;
  41. height: 2rem;
  42. align-items: center;
  43. }
  44. .sName {
  45. color: #fff;
  46. font-size: 16px;
  47. margin-left: 10px;
  48. }
  49. .logoImg>img {
  50. width: 100%;
  51. height: 100%;
  52. }
  53. .logoImg {
  54. width: 1.5rem;
  55. height: 1.5rem;
  56. margin: auto 0 auto 1rem;
  57. }
  58. .swiper-pagination {
  59. bottom: -1rem !important;
  60. }
  61. .bg {
  62. width: 100%;
  63. height: 100%;
  64. background: url(./img/star.png) no-repeat center 100%;
  65. background-size: cover;
  66. }
  67. @media only screen and (max-width: 500px) {
  68. .swiper-container {
  69. height: 32rem;
  70. top: 30%;
  71. }
  72. .swiper-slide {
  73. height: 32rem;
  74. }
  75. .swiper-pagination {
  76. bottom: -2rem !important;
  77. }
  78. }
  79. </style>
  80. </head>
  81. <body>
  82. <div class="bg">
  83. <div class="logo">
  84. <div class="logoImg"><img src="./img/logo.png" alt=""></div>
  85. <div class="sName">深圳市民治中学</div>
  86. </div>
  87. <!-- Swiper -->
  88. <div class="swiper-container">
  89. <div class="swiper-wrapper">
  90. <div class="swiper-slide" style="background-image:url(img/first.png)"></div>
  91. <div class="swiper-slide" style="background-image:url(img/second.png)"></div>
  92. <div class="swiper-slide" style="background-image:url(img/third.png)"></div>
  93. <div class="swiper-slide" style="background-image:url(img/fourth.png)"></div>
  94. <div class="swiper-slide" style="background-image:url(img/fiveth.png)"></div>
  95. </div>
  96. <!-- Add Pagination -->
  97. <div class="swiper-pagination"></div>
  98. </div>
  99. </div>
  100. <!-- Swiper JS -->
  101. <script src="./dist/js/swiper.min.js"></script>
  102. <!-- Initialize Swiper -->
  103. <script>
  104. var swiper = new Swiper('.swiper-container', {
  105. pagination: '.swiper-pagination',
  106. effect: 'cube',
  107. grabCursor: true,
  108. cube: {
  109. shadow: true,
  110. slideShadows: true,
  111. shadowOffset: 20,
  112. shadowScale: 0.94
  113. }
  114. });
  115. let htmlwidth = document.documentElement.clientWidth || document.body.clientWidth  
  116. let htmlDom = document.getElementsByTagName('html')[0];  
  117. if (htmlwidth > 750) {
  118. htmlwidth = 750
  119. }  
  120. htmlDom.style.fontSize = htmlwidth / 20 + 'px';  
  121. window.onresize = function() {   
  122. let htmlwidth = document.documentElement.clientWidth || document.body.clientWidth   
  123. let htmlDom = document.getElementsByTagName('html')[0];   
  124. if (htmlwidth > 750) {
  125. htmlwidth = 750
  126. }   
  127. htmlDom.style.fontSize = htmlwidth / 20 + 'px';  
  128. };
  129. </script>
  130. </body>
  131. </html>