当前位置:   article > 正文

HTML 相册2.0 通过css 获取图片资源 2024/7/22 日志

HTML 相册2.0 通过css 获取图片资源 2024/7/22 日志

简单方法通过css 绕过同源策略 以获取资源

  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>水面倒影</title>
  7. </head>
  8. <style>
  9. * {
  10. margin: 0;
  11. padding: 0;
  12. background-color: black;
  13. overflow: hidden;
  14. }
  15. :root {
  16. --url1: url('https://p1.ssl.qhimgs1.com/sdr/400__/t01ad51c404cedd035b.jpg');
  17. --url2: url('https://p1.ssl.qhimgs1.com/sdr/400__/t01c1a45e5e8cd59ed1.jpg');
  18. --url4: url('https://p1.ssl.qhimgs1.com/sdr/400__/t0476de4a34f088a8a7.jpg');
  19. --url5: url('https://p1.ssl.qhimgs1.com/sdr/400__/t04a17109704054cb5b.jpg');
  20. --url6: url('https://p2.ssl.qhimgs1.com/sdr/400__/t03e8c2d4c1fba3f1c2.jpg');
  21. --url7: url('https://p0.ssl.qhimgs1.com/sdr/400__/t01801242cf98b4c440.jpg');
  22. --url8: url('https://p2.ssl.qhimgs1.com/sdr/400__/t0439d69c47c0d7c0e8.jpg');
  23. }
  24. body {
  25. box-sizing: border-box;
  26. position: relative;
  27. overflow: hidden;
  28. z-index: -1;
  29. }
  30. .boxa {
  31. position: relative;
  32. margin: 0;
  33. padding: 0;
  34. width: 100vw;
  35. height: 500px;
  36. display: flex;
  37. justify-content: center;
  38. align-items: center;
  39. background-color: transparent;
  40. z-index: 1;
  41. }
  42. div:not(.boxa):not(.void):hover {
  43. transform: translateZ(200px) translateY(10px) rotateY(20deg);
  44. perspective: 1000px;
  45. -webkit-box-reflect: below 0px -webkit-linear-gradient(top, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.5));
  46. box-shadow: 0 0 20px 0 rgba(225, 136, 41, 0.5),
  47. 0 0 25px 0 rgba(7, 229, 29, 0.5),
  48. 0 0 30px 0 rgba(214, 46, 184, 0.5);
  49. }
  50. #t1:active {
  51. transform: translateX(600px) scale(2);
  52. box-shadow: 0 0 20px 10px rgba(134, 198, 237, 1),
  53. 0 0 25px 15px rgba(3, 250, 213, 1),
  54. 0 0 30px 20px rgba(244, 3, 39, 1);
  55. }
  56. #t2:active {
  57. transform: translateX(400px) scale(2);
  58. box-shadow: 0 0 20px 10px rgba(255, 165, 0, 1),
  59. 0 0 25px 15px rgba(255, 0, 255, 1),
  60. 0 0 30px 20px rgba(0, 255, 0, 1);
  61. }
  62. #t3:active {
  63. transform: translateX(200px) scale(2);
  64. box-shadow: 0 0 20px 10px rgba(0, 0, 255, 1),
  65. 0 0 25px 15px rgba(255, 0, 0, 1),
  66. 0 0 30px 20px rgba(0, 255, 255, 1);
  67. }
  68. #t4:active {
  69. transform: scale(2);
  70. box-shadow: 0 0 20px 10px rgba(128, 0, 128, 1),
  71. 0 0 25px 15px rgba(255, 255, 0, 1),
  72. 0 0 30px 20px rgba(0, 128, 128, 1);
  73. }
  74. #t5:active {
  75. transform: translateX(-200px) scale(2);
  76. box-shadow: 0 0 20px 10px rgba(128, 128, 0, 1),
  77. 0 0 25px 15px rgba(128, 0, 0, 1),
  78. 0 0 30px 20px rgba(0, 128, 0, 1);
  79. }
  80. #t6:active {
  81. transform: translateX(-400px) scale(2);
  82. box-shadow: 0 0 20px 10px rgba(0, 0, 0, 1),
  83. 0 0 25px 15px rgba(255, 255, 255, 1),
  84. 0 0 30px 20px rgba(128, 128, 128, 1);
  85. }
  86. #t7:active {
  87. transform: translateX(-600px) scale(2);
  88. box-shadow: 0 0 20px 10px rgba(255, 255, 128, 1),
  89. 0 0 25px 15px rgba(128, 255, 255, 1),
  90. 0 0 30px 20px rgba(255, 128, 128, 1);
  91. }
  92. .test1 {
  93. overflow: hidden;
  94. width: 200px;
  95. height: 300px;
  96. background-image: var(--url1);
  97. background-repeat: no-repeat;
  98. background-position: center;
  99. background-size: cover;
  100. border: 2px solid rgb(255, 255, 255);
  101. }
  102. .test2 {
  103. overflow: hidden;
  104. width: 200px;
  105. height: 300px;
  106. background-image: var(--url2);
  107. background-repeat: no-repeat;
  108. background-position: center;
  109. background-size: cover;
  110. border: 2px solid rgb(255, 255, 255);
  111. }
  112. .test3 {
  113. overflow: hidden;
  114. width: 200px;
  115. height: 300px;
  116. background-image: var(--url4);
  117. background-repeat: no-repeat;
  118. background-position: center;
  119. background-size: cover;
  120. border: 2px solid rgb(255, 255, 255);
  121. }
  122. .test4 {
  123. overflow: hidden;
  124. width: 200px;
  125. height: 300px;
  126. background-image: var(--url5);
  127. background-repeat: no-repeat;
  128. background-position: center;
  129. background-size: cover;
  130. border: 2px solid rgb(255, 255, 255);
  131. }
  132. .test5 {
  133. overflow: hidden;
  134. width: 200px;
  135. height: 300px;
  136. background-image: var(--url6);
  137. background-repeat: no-repeat;
  138. background-position: center;
  139. background-size: cover;
  140. border: 2px solid rgb(255, 255, 255);
  141. }
  142. .test6 {
  143. overflow: hidden;
  144. width: 200px;
  145. height: 300px;
  146. background-image: var(--url7);
  147. background-repeat: no-repeat;
  148. background-position: center;
  149. background-size: cover;
  150. border: 2px solid rgb(255, 255, 255);
  151. }
  152. .test7 {
  153. overflow: hidden;
  154. width: 200px;
  155. height: 300px;
  156. background-image: var(--url8);
  157. background-repeat: no-repeat;
  158. background-position: center;
  159. background-size: cover;
  160. border: 2px solid rgb(255, 255, 255);
  161. }
  162. .void {
  163. top: -16vh;
  164. z-index: 0;
  165. position: relative;
  166. width: 100vw;
  167. height: 500px;
  168. background-image: url("https://p3.ssl.qhimgs1.com/sdr/400__/t011d51db67bfe62a1d.gif");
  169. background-repeat: no-repeat;
  170. background-position: center;
  171. background-size: cover;
  172. opacity: 0.5;
  173. }
  174. </style>
  175. <body>
  176. <div id="box" class="boxa">
  177. <div id="t1" class="test1"></div>
  178. <div id="t2" class="test2"></div>
  179. <div id="t3" class="test3"></div>
  180. <div id="t4" class="test4"></div>
  181. <div id="t5" class="test5"></div>
  182. <div id="t6" class="test6"></div>
  183. <div id="t7" class="test7"></div>
  184. </div>
  185. <div class="void">显示图片</div>
  186. </body>
  187. </html>

效果展示 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Guff_9hys/article/detail/889132
推荐阅读
相关标签
  

闽ICP备14008679号