• 【css | loading】好看的loading特效


    示例:

    https://code.juejin.cn/pen/7277764394618978365

    html

    1. <div class="pl">
    2. <div class="pl__dot">div>
    3. <div class="pl__dot">div>
    4. <div class="pl__dot">div>
    5. <div class="pl__dot">div>
    6. <div class="pl__dot">div>
    7. <div class="pl__dot">div>
    8. <div class="pl__dot">div>
    9. <div class="pl__dot">div>
    10. <div class="pl__dot">div>
    11. <div class="pl__dot">div>
    12. <div class="pl__dot">div>
    13. <div class="pl__dot">div>
    14. <div class="pl__text">Loading…div>
    15. div>

    css

    1. :root {
    2. --bg: #454954;
    3. --fg: #e3e4e8;
    4. --fg-t: rgba(227, 228, 232, 0.5);
    5. --primary1: #255ff4;
    6. --primary2: #5583f6;
    7. --trans-dur: 0.3s;
    8. font-size: calc(16px + (20 - 16) * (100vw - 320px) / (1280 - 320));
    9. }
    10. body {
    11. background-color: var(--bg);
    12. background-image: linear-gradient(135deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.2));
    13. color: var(--fg);
    14. font: 1em/1.5 "Varela Round", Helvetica, sans-serif;
    15. height: 100vh;
    16. min-height: 360px;
    17. display: grid;
    18. place-items: center;
    19. transition: background-color var(--trans-dur), color var(--trans-dur);
    20. }
    21. .pl {
    22. box-shadow: 2em 0 2em rgba(0, 0, 0, 0.2) inset, -2em 0 2em rgba(255, 255, 255, 0.1) inset;
    23. display: flex;
    24. justify-content: center;
    25. align-items: center;
    26. position: relative;
    27. letter-spacing: 0.1em;
    28. text-transform: uppercase;
    29. transform: rotateX(30deg) rotateZ(45deg);
    30. width: 15em;
    31. height: 15em;
    32. }
    33. .pl, .pl__dot {
    34. border-radius: 50%;
    35. }
    36. .pl__dot {
    37. animation-name: shadow;
    38. box-shadow: 0.1em 0.1em 0 0.1em black, 0.3em 0 0.3em rgba(0, 0, 0, 0.5);
    39. top: calc(50% - 0.75em);
    40. left: calc(50% - 0.75em);
    41. width: 1.5em;
    42. height: 1.5em;
    43. }
    44. .pl__dot, .pl__dot:before, .pl__dot:after {
    45. animation-duration: 2s;
    46. animation-iteration-count: infinite;
    47. position: absolute;
    48. }
    49. .pl__dot:before, .pl__dot:after {
    50. content: "";
    51. display: block;
    52. left: 0;
    53. width: inherit;
    54. transition: background-color var(--trans-dur);
    55. }
    56. .pl__dot:before {
    57. animation-name: pushInOut1;
    58. background-color: var(--bg);
    59. border-radius: inherit;
    60. box-shadow: 0.05em 0 0.1em rgba(255, 255, 255, 0.2) inset;
    61. height: inherit;
    62. z-index: 1;
    63. }
    64. .pl__dot:after {
    65. animation-name: pushInOut2;
    66. background-color: var(--primary1);
    67. border-radius: 0.75em;
    68. box-shadow: 0.1em 0.3em 0.2em rgba(255, 255, 255, 0.4) inset, 0 -0.4em 0.2em #2e3138 inset, 0 -1em 0.25em rgba(0, 0, 0, 0.3) inset;
    69. bottom: 0;
    70. clip-path: polygon(0 75%, 100% 75%, 100% 100%, 0 100%);
    71. height: 3em;
    72. transform: rotate(-45deg);
    73. transform-origin: 50% 2.25em;
    74. }
    75. .pl__dot:nth-child(1) {
    76. transform: rotate(0deg) translateX(5em) rotate(0deg);
    77. z-index: 5;
    78. }
    79. .pl__dot:nth-child(1), .pl__dot:nth-child(1):before, .pl__dot:nth-child(1):after {
    80. animation-delay: 0s;
    81. }
    82. .pl__dot:nth-child(2) {
    83. transform: rotate(-30deg) translateX(5em) rotate(30deg);
    84. z-index: 4;
    85. }
    86. .pl__dot:nth-child(2), .pl__dot:nth-child(2):before, .pl__dot:nth-child(2):after {
    87. animation-delay: -0.1666666667s;
    88. }
    89. .pl__dot:nth-child(3) {
    90. transform: rotate(-60deg) translateX(5em) rotate(60deg);
    91. z-index: 3;
    92. }
    93. .pl__dot:nth-child(3), .pl__dot:nth-child(3):before, .pl__dot:nth-child(3):after {
    94. animation-delay: -0.3333333333s;
    95. }
    96. .pl__dot:nth-child(4) {
    97. transform: rotate(-90deg) translateX(5em) rotate(90deg);
    98. z-index: 2;
    99. }
    100. .pl__dot:nth-child(4), .pl__dot:nth-child(4):before, .pl__dot:nth-child(4):after {
    101. animation-delay: -0.5s;
    102. }
    103. .pl__dot:nth-child(5) {
    104. transform: rotate(-120deg) translateX(5em) rotate(120deg);
    105. z-index: 1;
    106. }
    107. .pl__dot:nth-child(5), .pl__dot:nth-child(5):before, .pl__dot:nth-child(5):after {
    108. animation-delay: -0.6666666667s;
    109. }
    110. .pl__dot:nth-child(6) {
    111. transform: rotate(-150deg) translateX(5em) rotate(150deg);
    112. z-index: 1;
    113. }
    114. .pl__dot:nth-child(6), .pl__dot:nth-child(6):before, .pl__dot:nth-child(6):after {
    115. animation-delay: -0.8333333333s;
    116. }
    117. .pl__dot:nth-child(7) {
    118. transform: rotate(-180deg) translateX(5em) rotate(180deg);
    119. z-index: 2;
    120. }
    121. .pl__dot:nth-child(7), .pl__dot:nth-child(7):before, .pl__dot:nth-child(7):after {
    122. animation-delay: -1s;
    123. }
    124. .pl__dot:nth-child(8) {
    125. transform: rotate(-210deg) translateX(5em) rotate(210deg);
    126. z-index: 3;
    127. }
    128. .pl__dot:nth-child(8), .pl__dot:nth-child(8):before, .pl__dot:nth-child(8):after {
    129. animation-delay: -1.1666666667s;
    130. }
    131. .pl__dot:nth-child(9) {
    132. transform: rotate(-240deg) translateX(5em) rotate(240deg);
    133. z-index: 4;
    134. }
    135. .pl__dot:nth-child(9), .pl__dot:nth-child(9):before, .pl__dot:nth-child(9):after {
    136. animation-delay: -1.3333333333s;
    137. }
    138. .pl__dot:nth-child(10) {
    139. transform: rotate(-270deg) translateX(5em) rotate(270deg);
    140. z-index: 5;
    141. }
    142. .pl__dot:nth-child(10), .pl__dot:nth-child(10):before, .pl__dot:nth-child(10):after {
    143. animation-delay: -1.5s;
    144. }
    145. .pl__dot:nth-child(11) {
    146. transform: rotate(-300deg) translateX(5em) rotate(300deg);
    147. z-index: 6;
    148. }
    149. .pl__dot:nth-child(11), .pl__dot:nth-child(11):before, .pl__dot:nth-child(11):after {
    150. animation-delay: -1.6666666667s;
    151. }
    152. .pl__dot:nth-child(12) {
    153. transform: rotate(-330deg) translateX(5em) rotate(330deg);
    154. z-index: 6;
    155. }
    156. .pl__dot:nth-child(12), .pl__dot:nth-child(12):before, .pl__dot:nth-child(12):after {
    157. animation-delay: -1.8333333333s;
    158. }
    159. .pl__text {
    160. font-size: 0.75em;
    161. max-width: 5rem;
    162. position: relative;
    163. text-shadow: 0 0 0.1em var(--fg-t);
    164. transform: rotateZ(-45deg);
    165. }
    166. /* Animations */
    167. @keyframes shadow {
    168. from {
    169. animation-timing-function: ease-in;
    170. box-shadow: 0.1em 0.1em 0 0.1em black, 0.3em 0 0.3em rgba(0, 0, 0, 0.3);
    171. }
    172. 25% {
    173. animation-timing-function: ease-out;
    174. box-shadow: 0.1em 0.1em 0 0.1em black, 0.8em 0 0.8em rgba(0, 0, 0, 0.5);
    175. }
    176. 50%, to {
    177. box-shadow: 0.1em 0.1em 0 0.1em black, 0.3em 0 0.3em rgba(0, 0, 0, 0.3);
    178. }
    179. }
    180. @keyframes pushInOut1 {
    181. from {
    182. animation-timing-function: ease-in;
    183. background-color: var(--bg);
    184. transform: translate(0, 0);
    185. }
    186. 25% {
    187. animation-timing-function: ease-out;
    188. background-color: var(--primary2);
    189. transform: translate(-71%, -71%);
    190. }
    191. 50%, to {
    192. background-color: var(--bg);
    193. transform: translate(0, 0);
    194. }
    195. }
    196. @keyframes pushInOut2 {
    197. from {
    198. animation-timing-function: ease-in;
    199. background-color: var(--bg);
    200. clip-path: polygon(0 75%, 100% 75%, 100% 100%, 0 100%);
    201. }
    202. 25% {
    203. animation-timing-function: ease-out;
    204. background-color: var(--primary1);
    205. clip-path: polygon(0 25%, 100% 25%, 100% 100%, 0 100%);
    206. }
    207. 50%, to {
    208. background-color: var(--bg);
    209. clip-path: polygon(0 75%, 100% 75%, 100% 100%, 0 100%);
    210. }
    211. }

     

     

  • 相关阅读:
    android studio 常见问题
    # HTB-Tier2- Vaccine
    并发与并行,同步和异步,Go lang1.18入门精炼教程,由白丁入鸿儒,Go lang并发编程之GoroutineEP13
    2023 Google 开发者大会 – AI 领域的技术更新
    金仓数据库KingbaseES服务器应用参考手册--11. sys_upgrade
    对话祁隆《借我星光》作词人温暖:已获知和合国际收购信息
    vue中常用修饰符
    怎么使用股票委托下单接口?
    爬虫HTTP代理:获取多种类型数据的神器
    2024年经典【自动化面试题】附答案
  • 原文地址:https://blog.csdn.net/weixin_43340372/article/details/132832390