<..._background: url(../img/02.png) no-repeat 0 0;">
当前位置:   article > 正文

抖音上很火的3D立体动态相册实现代码!_background: url(../img/02.png) no-repeat 0 0;

background: url(../img/02.png) no-repeat 0 0;

html代码

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>酷炫3d</title>
  6. <link type="text/css" href="css/style.css" rel="stylesheet" />
  7. </head>
  8. <body>
  9. <div class="box">
  10. <ul class="minbox">
  11. <li>
  12. <img src="./img/01.jpg" alt="">
  13. </li>
  14. <li>
  15. <img src="./img/02.jpg" alt="">
  16. </li>
  17. <li>
  18. <img src="./img/03.jpg" alt="">
  19. </li>
  20. <li>
  21. <img src="./img/04.jpg" alt="">
  22. </li>
  23. <li>
  24. <img src="./img/05.jpg" alt="">
  25. </li>
  26. <li>
  27. <img src="./img/06.jpg" alt="">
  28. </li>
  29. </ul>
  30. <ol class="maxbox">
  31. <li>
  32. <img src="./img/1.jpg" alt="">
  33. </li>
  34. <li>
  35. <img src="./img/2.jpg" alt="">
  36. </li>
  37. <li>
  38. <img src="./img/3.jpg" alt="">
  39. </li>
  40. <li>
  41. <img src="./img/4.jpg" alt="">
  42. </li>
  43. <li>
  44. <img src="./img/5.jpg" alt="">
  45. </li>
  46. <li>
  47. <img src="./img/6.jpg" alt="">
  48. </li>
  49. </ol>
  50. </div>
  51. </body>
  52. </html>

css重要的

  1. @charset "utf-8";
  2. *{
  3. margin:0;
  4. padding:0;
  5. }
  6. body{
  7. max-width: 100%;
  8. min-width: 100%;
  9. height: 100%;
  10. background-size: cover;
  11. background-repeat: no-repeat;
  12. background-attachment: fixed;
  13. background-size:100% 100%;
  14. position: absolute;
  15. margin-left: auto;
  16. margin-right: auto;
  17. }
  18. li{
  19. list-style: none;
  20. }
  21. .box{
  22. width:200px;
  23. height:200px;
  24. background-size: cover;
  25. background-repeat: no-repeat;
  26. background-attachment: fixed;
  27. background-size:100% 100%;
  28. position: absolute;
  29. margin-left: 42%;
  30. margin-top: 22%;
  31. -webkit-transform-style:preserve-3d;
  32. -webkit-transform:rotateX(13deg);
  33. -webkit-animation:move 5s linear infinite;
  34. }
  35. .minbox{
  36. width:100px;
  37. height:100px;
  38. position: absolute;
  39. left:50px;
  40. top:30px;
  41. -webkit-transform-style:preserve-3d;
  42. }
  43. .minbox li{
  44. width:100px;
  45. height:100px;
  46. position: absolute;
  47. left:0;
  48. top:0;
  49. }
  50. .minbox li:nth-child(1){
  51. /*background: url(../img/01.png) no-repeat 0 0;*/
  52. -webkit-transform:translateZ(50px);
  53. }
  54. .minbox li:nth-child(1) img{
  55. width: 100%;
  56. height: 100%;
  57. }
  58. .minbox li:nth-child(2) img{
  59. width: 100%;
  60. height: 100%;
  61. }
  62. .minbox li:nth-child(3) img{
  63. width: 100%;
  64. height: 100%;
  65. }
  66. .minbox li:nth-child(4) img{
  67. width: 100%;
  68. height: 100%;
  69. }
  70. .minbox li:nth-child(5) img{
  71. width: 100%;
  72. height: 100%;
  73. }
  74. .minbox li:nth-child(6) img{
  75. width: 100%;
  76. height: 100%;
  77. }
  78. .minbox li:nth-child(2){
  79. /*background: url(../img/02.png) no-repeat 0 0;*/
  80. -webkit-transform:rotateX(180deg) translateZ(50px);
  81. }
  82. .minbox li:nth-child(3){
  83. /*background: url(../img/03.png) no-repeat 0 0;*/
  84. -webkit-transform:rotateX(-90deg) translateZ(50px);
  85. }
  86. .minbox li:nth-child(4){
  87. /*background: url(../img/04.png) no-repeat 0 0;*/
  88. -webkit-transform:rotateX(90deg) translateZ(50px);
  89. }
  90. .minbox li:nth-child(5){
  91. /*background: url(../img/05.png) no-repeat 0 0;*/
  92. -webkit-transform:rotateY(-90deg) translateZ(50px);
  93. }
  94. .minbox li:nth-child(6){
  95. /*background: url(../img/06.png) no-repeat 0 0;*/
  96. -webkit-transform:rotateY(90deg) translateZ(50px);
  97. }
  98. .maxbox li:nth-child(1){
  99. /*background: url(../img/1.png) no-repeat 0 0;*/
  100. -webkit-transform:translateZ(50px);
  101. }
  102. .maxbox li:nth-child(2){
  103. /*background: url(../img/2.png) no-repeat 0 0;*/
  104. -webkit-transform:translateZ(50px);
  105. }
  106. .maxbox li:nth-child(3){
  107. /*background: url(../img/3.png) no-repeat 0 0;*/
  108. -webkit-transform:rotateX(-90deg) translateZ(50px);
  109. }
  110. .maxbox li:nth-child(4){
  111. /*background: url(../img/4.png) no-repeat 0 0;*/
  112. -webkit-transform:rotateX(90deg) translateZ(50px);
  113. }
  114. .maxbox li:nth-child(5){
  115. /*background: url(../img/5.png) no-repeat 0 0;*/
  116. -webkit-transform:rotateY(-90deg) translateZ(50px);
  117. }
  118. .maxbox li:nth-child(6){
  119. /*background: url(../img/6.png) no-repeat 0 0;*/
  120. -webkit-transform:rotateY(90deg) translateZ(50px);
  121. }
  122. .maxbox{
  123. width: 800px;
  124. height: 400px;
  125. position: absolute;
  126. left: 0;
  127. top: -20px;
  128. -webkit-transform-style: preserve-3d;
  129. }
  130. .maxbox li{
  131. width: 200px;
  132. height: 200px;
  133. background: #fff;
  134. border:1px solid #ccc;
  135. position: absolute;
  136. left: 0;
  137. top: 0;
  138. opacity: 0.2;
  139. -webkit-transition:all 1s ease;
  140. }
  141. .maxbox li:nth-child(1){
  142. -webkit-transform:translateZ(100px);
  143. }
  144. .maxbox li:nth-child(1) img{
  145. width: 100%;
  146. height: 100%;
  147. }
  148. .maxbox li:nth-child(2) img{
  149. width: 100%;
  150. height: 100%;
  151. }
  152. .maxbox li:nth-child(3) img{
  153. width: 100%;
  154. height: 100%;
  155. }
  156. .maxbox li:nth-child(4) img{
  157. width: 100%;
  158. height: 100%;
  159. }
  160. .maxbox li:nth-child(5) img{
  161. width: 100%;
  162. height: 100%;
  163. }
  164. .maxbox li:nth-child(6) img{
  165. width: 100%;
  166. height: 100%;
  167. }
  168. .maxbox li:nth-child(2){
  169. -webkit-transform:rotateX(180deg) translateZ(100px);
  170. }
  171. .maxbox li:nth-child(3){
  172. -webkit-transform:rotateX(-90deg) translateZ(100px);
  173. }
  174. .maxbox li:nth-child(4){
  175. -webkit-transform:rotateX(90deg) translateZ(100px);
  176. }
  177. .maxbox li:nth-child(5){
  178. -webkit-transform:rotateY(-90deg) translateZ(100px);
  179. }
  180. .maxbox li:nth-child(6){
  181. -webkit-transform:rotateY(90deg) translateZ(100px);
  182. }
  183. .box:hover ol li:nth-child(1){
  184. -webkit-transform:translateZ(300px);
  185. width: 400px;
  186. height: 400px;
  187. opacity: 0.8;
  188. left: -100px;
  189. top: -100px;
  190. }
  191. .box:hover ol li:nth-child(2){
  192. -webkit-transform:rotateX(180deg) translateZ(300px);
  193. width: 400px;
  194. height: 400px;
  195. opacity: 0.8;
  196. left: -100px;
  197. top: -100px;
  198. }
  199. .box:hover ol li:nth-child(3){
  200. -webkit-transform:rotateX(-90deg) translateZ(300px);
  201. width: 400px;
  202. height: 400px;
  203. opacity: 0.8;
  204. left: -100px;
  205. top: -100px;
  206. }
  207. .box:hover ol li:nth-child(4){
  208. -webkit-transform:rotateX(90deg) translateZ(300px);
  209. width: 400px;
  210. height: 400px;
  211. opacity: 0.8;
  212. left: -100px;
  213. top: -100px;
  214. }
  215. .box:hover ol li:nth-child(5){
  216. -webkit-transform:rotateY(-90deg) translateZ(300px);
  217. width: 400px;
  218. height: 400px;
  219. opacity: 0.8;
  220. left: -100px;
  221. top: -100px;
  222. }
  223. .box:hover ol li:nth-child(6){
  224. -webkit-transform:rotateY(90deg) translateZ(300px);
  225. width: 400px;
  226. height: 400px;
  227. opacity: 0.8;
  228. left: -100px;
  229. top: -100px;
  230. }
  231. @keyframes move{
  232. 0%{
  233. -webkit-transform: rotateX(13deg) rotateY(0deg);
  234. }
  235. 100%{
  236. -webkit-transform:rotateX(13deg) rotateY(360deg);
  237. }
  238. }

1.jpg  2.jpg~6.jpg是外层

01.jpg~06.jpg是里层

图片大小可随意设置  建议 外层100*100  里层400*400

如需要更改为png图片需要更改index.html的代码

 

提取代码无脑往img 里面放对应的图片就行

链接: https://pan.baidu.com/s/1_Xi1ohbwHSevvFM0qSEqJA 提取码: s86f 

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

闽ICP备14008679号