cid1016 使用HTML CSS 实现一个有趣的加载页面

index.html

  1. <!DOCTYPE html>
  2. <html lang="en" dir="ltr">
  3. <head>
  4. <meta charset="utf-8">
  5. <title></title>
  6. <link rel="stylesheet" href="style.css">
  7. </head>
  8. <body>
  9. <div class="container">
  10. <div class="box"></div>
  11. <div class="box"></div>
  12. </div>
  13. </body>
  14. </html>
<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="style.css">
  </head>
  <body>
    <div class="container">
      <div class="box"></div>
      <div class="box"></div>
    </div>
  </body>
</html>

 

style.css

  1. body{
  2. margin: 0;
  3. padding: 0;
  4. background: #344;
  5. }
  6. .container{
  7. position: absolute;
  8. left: 50%;
  9. top: 50%;
  10. transform: translate(-50%,-50%);
  11. width: 60px;
  12. height: 60px;
  13. }
  14. .box{
  15. position: absolute;
  16. width: 30px;
  17. height: 30px;
  18. background: #e74c3c;
  19. }
  20. .box:nth-child(1){
  21. animation: a1 2s infinite linear;
  22. }
  23. .box:nth-child(2){
  24. animation: a2 2s infinite linear;
  25. }
  26. @keyframes a1 {
  27. 0%{
  28. top: 0;
  29. left: 0;
  30. width: 30px;
  31. height: 30px;
  32. }
  33. 12.5%{
  34. top: 0;
  35. left: 0;
  36. width: 60px;
  37. height: 30px;
  38. }
  39. 25%{
  40. top: 0;
  41. left: 0;
  42. width: 60px;
  43. height: 30px;
  44. }
  45. 37.5%{
  46. top: 0;
  47. left: 30px;
  48. width: 30px;
  49. height: 30px;
  50. }
  51. 50%{
  52. top: 0;
  53. left: 30px;
  54. width: 30px;
  55. height: 30px;
  56. }
  57. 62.5%{
  58. top: 0;
  59. left: 30px;
  60. width: 30px;
  61. height: 60px;
  62. }
  63. 75%{
  64. top: 0;
  65. left: 30px;
  66. width: 30px;
  67. height: 60px;
  68. }
  69. 87.5%{
  70. top: 30px;
  71. left: 30px;
  72. width: 30px;
  73. height: 30px;
  74. }
  75. 100%{
  76. top: 30px;
  77. left: 30px;
  78. width: 30px;
  79. height: 30px;
  80. }
  81. }
  82. @keyframes a2 {
  83. 0%{
  84. right: 0;
  85. bottom: 0;
  86. width: 30px;
  87. height: 30px;
  88. }
  89. 12.5%{
  90. right: 0;
  91. bottom: 0;
  92. width: 30px;
  93. height: 30px;
  94. }
  95. 25%{
  96. right: 0;
  97. bottom: 0;
  98. width: 60px;
  99. height: 30px;
  100. }
  101. 37.5%{
  102. right: 0;
  103. bottom: 0;
  104. width: 60px;
  105. height: 30px;
  106. }
  107. 50%{
  108. right: 30px;
  109. bottom: 0;
  110. width: 30px;
  111. height: 30px;
  112. }
  113. 62.5%{
  114. right: 30px;
  115. bottom: 0;
  116. width: 30px;
  117. height: 30px;
  118. }
  119. 75%{
  120. right: 30px;
  121. bottom: 0;
  122. width: 30px;
  123. height: 60px;
  124. }
  125. 87.5%{
  126. right: 30px;
  127. bottom: 0;
  128. width: 30px;
  129. height: 60px;
  130. }
  131. 100%{
  132. right: 30px;
  133. bottom: 30px;
  134. width: 30px;
  135. height: 30px;
  136. }
  137. }
body{
  margin: 0;
  padding: 0;
  background: #344;
}


.container{
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
  width: 60px;
  height: 60px;
}

.box{
  position: absolute;
  width: 30px;
  height: 30px;
  background: #e74c3c;
}

.box:nth-child(1){
  animation: a1 2s infinite linear;
}

.box:nth-child(2){
  animation: a2 2s infinite linear;
}


@keyframes a1 {
  0%{
    top: 0;
    left: 0;
    width: 30px;
    height: 30px;
  }
  12.5%{
    top: 0;
    left: 0;
    width: 60px;
    height: 30px;
  }
  25%{
    top: 0;
    left: 0;
    width: 60px;
    height: 30px;
  }
  37.5%{
    top: 0;
    left: 30px;
    width: 30px;
    height: 30px;
  }
  50%{
    top: 0;
    left: 30px;
    width: 30px;
    height: 30px;
  }
  62.5%{
    top: 0;
    left: 30px;
    width: 30px;
    height: 60px;
  }
  75%{
    top: 0;
    left: 30px;
    width: 30px;
    height: 60px;
  }
  87.5%{
    top: 30px;
    left: 30px;
    width: 30px;
    height: 30px;
  }
  100%{
    top: 30px;
    left: 30px;
    width: 30px;
    height: 30px;
  }
}

@keyframes a2 {
  0%{
    right: 0;
    bottom: 0;
    width: 30px;
    height: 30px;
  }
  12.5%{
    right: 0;
    bottom: 0;
    width: 30px;
    height: 30px;
  }
  25%{
    right: 0;
    bottom: 0;
    width: 60px;
    height: 30px;
  }
  37.5%{
    right: 0;
    bottom: 0;
    width: 60px;
    height: 30px;
  }
  50%{
    right: 30px;
    bottom: 0;
    width: 30px;
    height: 30px;
  }
  62.5%{
    right: 30px;
    bottom: 0;
    width: 30px;
    height: 30px;
  }
  75%{
    right: 30px;
    bottom: 0;
    width: 30px;
    height: 60px;
  }
  87.5%{
    right: 30px;
    bottom: 0;
    width: 30px;
    height: 60px;
  }
  100%{
    right: 30px;
    bottom: 30px;
    width: 30px;
    height: 30px;
  }
}

 

让链接同时具备两种打开方式

获取源码: Loading 1
下载数:45人次, 文件大小: 94 B, 上传日期: 2020年-11 月-25日

公众号回复:gcode  获取解压密码

qrcode_for_gh_6ea2c28a1709_258 (1)

1,780 人查阅

类似文章