当前位置:Gxlcms > css > 常见的几种loding效果实现

常见的几种loding效果实现

时间:2021-07-01 10:21:17 帮助过:33人阅读

这次我们来说一下常见的几种loding效果实现,loding效果实现需要注意哪几点,下面就是实战案例,一起来看一下。

  1. <html>
  2. <head>
  3. <meta charset="UTF-8">
  4. <title>Loading</title>
  5. <link rel="stylesheet" type="text/css" href="loading.css">
  6. <style>
  7. .loader {
  8. float: left;
  9. }
  10. .loader {
  11. position: relative;
  12. width: 5rem;
  13. height: 5rem;
  14. }
  15. .loader.small {
  16. -webkit-transform: scale(.5);
  17. transform: scale(.5);
  18. }
  19. .loader.circle-line,
  20. .loader.circle-round {
  21. height: 5rem;
  22. }
  23. /*circle-line*/
  24. .loader.circle-line span {
  25. position: absolute;
  26. display: inline-block;
  27. width: 1.5rem;
  28. height: .5rem;
  29. border-top-left-radius: .25rem;
  30. border-bottom-left-radius: .25rem;
  31. background: #1ABC9C;
  32. opacity: .05;
  33. -webkit-animation: circle-line 1s ease infinite;
  34. animation: circle-line 1s ease infinite;
  35. }
  36. .loader.circle-line span:nth-child(1) {
  37. top: 50%;
  38. left: 0;
  39. margin-top: -.25rem;
  40. -webkit-animation-delay: .13s;
  41. animation-delay: .13s;
  42. }
  43. .loader.circle-line span:nth-child(2) {
  44. top: 1rem;
  45. left: .5rem;
  46. -webkit-transform: rotate(45deg);
  47. transform: rotate(45deg);
  48. -webkit-animation-delay: .26s;
  49. animation-delay: .26s;
  50. }
  51. .loader.circle-line span:nth-child(3) {
  52. left: 50%;
  53. top: .5rem;
  54. margin-left: -.75rem;
  55. -webkit-transform: rotate(90deg);
  56. transform: rotate(90deg);
  57. -webkit-animation-delay: .39s;
  58. animation-delay: .39s;
  59. }
  60. .loader.circle-line span:nth-child(4) {
  61. right: .5rem;
  62. top: 1rem;
  63. -webkit-transform: rotate(145deg);
  64. transform: rotate(145deg);
  65. -webkit-animation-delay: .52s;
  66. animation-delay: .52s;
  67. }
  68. .loader.circle-line span:nth-child(5) {
  69. left: 3.5rem;
  70. top: 50%;
  71. margin-top: -.25rem;
  72. -webkit-transform: rotate(180deg);
  73. transform: rotate(180deg);
  74. -webkit-animation-delay: .65s;
  75. animation-delay: .65s;
  76. }
  77. .loader.circle-line span:nth-child(6) {
  78. bottom: 1rem;
  79. right: .5rem;
  80. -webkit-transform: rotate(-145deg);
  81. transform: rotate(-145deg);
  82. -webkit-animation-delay: .78s;
  83. animation-delay: .78s;
  84. }
  85. .loader.circle-line span:nth-child(7) {
  86. left: 50%;
  87. bottom: .5rem;
  88. margin-left: -15px;
  89. -webkit-transform: rotate(-90deg);
  90. transform: rotate(-90deg);
  91. -webkit-animation-delay: .91s;
  92. animation-delay: .91s;
  93. }
  94. .loader.circle-line span:nth-child(8) {
  95. bottom: 1rem;
  96. left: .5rem;
  97. -webkit-transform: rotate(-45deg);
  98. transform: rotate(-45deg);
  99. -webkit-animation-delay: 1.04s;
  100. animation-delay: 1.04s;
  101. }
  102. @keyframes circle-line {
  103. 0% {
  104. opacity: .05;
  105. }
  106. 100% {
  107. opacity: .7;
  108. }
  109. }
  110. @-webkit-keyframes circle-line {
  111. 0% {
  112. opacity: .05;
  113. }
  114. 100% {
  115. opacity: .7;
  116. }
  117. }
  118. /*circle-line-spin*/
  119. .loader.circle-line-spin .circle-line-inner {
  120. width: 100%;
  121. height: 100%;
  122. -webkit-animation: circle-line-spin 1.5s linear infinite;
  123. animation: circle-line-spin 1.5s linear infinite;
  124. }
  125. .loader.circle-line-spin span {
  126. position: absolute;
  127. display: inline-block;
  128. width: 1.5rem;
  129. height: .5rem;
  130. border-top-left-radius: .25rem;
  131. border-bottom-left-radius: .25rem;
  132. background: #1ABC9C;
  133. opacity: .7;
  134. }
  135. .loader.circle-line-spin span:nth-child(1) {
  136. top: 50%;
  137. left: 0;
  138. margin-top: -.25rem;
  139. }
  140. .loader.circle-line-spin span:nth-child(2) {
  141. top: 1rem;
  142. left: .5rem;
  143. -webkit-transform: rotate(45deg);
  144. transform: rotate(45deg);
  145. }
  146. .loader.circle-line-spin span:nth-child(3) {
  147. left: 50%;
  148. top: .5rem;
  149. margin-left: -.75rem;
  150. -webkit-transform: rotate(90deg);
  151. transform: rotate(90deg);
  152. }
  153. .loader.circle-line-spin span:nth-child(4) {
  154. right: .5rem;
  155. top: 1rem;
  156. -webkit-transform: rotate(145deg);
  157. transform: rotate(145deg);
  158. }
  159. .loader.circle-line-spin span:nth-child(5) {
  160. left: 3.5rem;
  161. top: 50%;
  162. margin-top: -.25rem;
  163. -webkit-transform: rotate(180deg);
  164. transform: rotate(180deg);
  165. }
  166. .loader.circle-line-spin span:nth-child(6) {
  167. bottom: 1rem;
  168. right: .5rem;
  169. -webkit-transform: rotate(-145deg);
  170. transform: rotate(-145deg);
  171. }
  172. .loader.circle-line-spin span:nth-child(7) {
  173. left: 50%;
  174. bottom: .5rem;
  175. margin-left: -15px;
  176. -webkit-transform: rotate(-90deg);
  177. transform: rotate(-90deg);
  178. }
  179. .loader.circle-line-spin span:nth-child(8) {
  180. bottom: 1rem;
  181. left: .5rem;
  182. -webkit-transform: rotate(-45deg);
  183. transform: rotate(-45deg);
  184. }
  185. @keyframes circle-line-spin {
  186. 0% {
  187. transform: rotate(0);
  188. }
  189. 100% {
  190. transform: rotate(360deg);
  191. }
  192. }
  193. @-webkit-keyframes circle-line-spin {
  194. 0% {
  195. -webkit-transform: rotate(0);
  196. }
  197. 100% {
  198. -webkit-transform: rotate(360deg);
  199. }
  200. }
  201. /*circle-round*/
  202. .loader.circle-round span {
  203. opacity: .05;
  204. -webkit-animation: circle-round 1s ease infinite;
  205. animation: circle-round 1s ease infinite;
  206. }
  207. .loader.circle-round-fade span {
  208. -webkit-animation: circle-round-fade 1s ease infinite;
  209. animation: circle-round-fade 1s ease infinite;
  210. }
  211. .loader.circle-round span,
  212. .loader.circle-round-fade span {
  213. position: absolute;
  214. width: .8rem;
  215. height: .8rem;
  216. display: inline-block;
  217. border-radius: 50%;
  218. background: #1ABC9C;
  219. }
  220. .loader.circle-round span:nth-child(1),
  221. .loader.circle-round-fade span:nth-child(1) {
  222. top: 50%;
  223. left: 0;
  224. margin-top: -.4rem;
  225. -webkit-animation-delay: -1.04s;
  226. animation-delay: -1.04s;
  227. }
  228. .loader.circle-round span:nth-child(2),
  229. .loader.circle-round-fade span:nth-child(2) {
  230. top: .7rem;
  231. left: .7rem;
  232. -webkit-animation-delay: -.91s;
  233. animation-delay: -.91s;
  234. }
  235. .loader.circle-round span:nth-child(3),
  236. .loader.circle-round-fade span:nth-child(3) {
  237. top: 0;
  238. left: 50%;
  239. margin-left: -.4rem;
  240. -webkit-animation-delay: -.78s;
  241. animation-delay: -.78s;
  242. }
  243. .loader.circle-round span:nth-child(4),
  244. .loader.circle-round-fade span:nth-child(4) {
  245. right: .7rem;
  246. top: .7rem;
  247. -webkit-animation-delay: -.65s;
  248. animation-delay: -.65s;
  249. }
  250. .loader.circle-round span:nth-child(5),
  251. .loader.circle-round-fade span:nth-child(5) {
  252. right: 0;
  253. top: 50%;
  254. margin-top: -.4rem;
  255. -webkit-animation-delay: -.52s;
  256. animation-delay: -.52s;
  257. }
  258. .loader.circle-round span:nth-child(6),
  259. .loader.circle-round-fade span:nth-child(6) {
  260. bottom: .7rem;
  261. right: .7rem;
  262. -webkit-animation-delay: -.39s;
  263. animation-delay: -.39s;
  264. }
  265. .loader.circle-round span:nth-child(7),
  266. .loader.circle-round-fade span:nth-child(7) {
  267. bottom: 0;
  268. left: 50%;
  269. margin-left: -.4rem;
  270. -webkit-animation-delay: -.26s;
  271. animation-delay: -.26s;
  272. }
  273. .loader.circle-round span:nth-child(8),
  274. .loader.circle-round-fade span:nth-child(8) {
  275. left: .7rem;
  276. bottom: .7rem;
  277. -webkit-animation-delay: -.13s;
  278. animation-delay: -.13s;
  279. }
  280. @keyframes circle-round {
  281. 0% {
  282. opacity: .05;
  283. }
  284. 100% {
  285. opacity: .7;
  286. }
  287. }
  288. @-webkit-keyframes circle-round {
  289. 0% {
  290. opacity: .05;
  291. }
  292. 100% {
  293. opacity: .7;
  294. }
  295. }
  296. @keyframes circle-round-fade {
  297. 0% {
  298. opacity: .25;
  299. transform: scale(.2);
  300. }
  301. 100% {
  302. opacity: 1;
  303. transform: scale(1);
  304. }
  305. }
  306. @-webkit-keyframes circle-round-fade {
  307. 0% {
  308. opacity: .25;
  309. transform: scale(.2);
  310. }
  311. 100% {
  312. opacity: 1;
  313. transform: scale(1);
  314. }
  315. }
  316. /*line-square*/
  317. .loader.line-square {
  318. width: 6rem;
  319. height: .8rem;
  320. }
  321. .loader.line-square span {
  322. position: absolute;
  323. top: 0;
  324. width: .8rem;
  325. height: .8rem;
  326. display: inline-block;
  327. background: #1ABC9C;
  328. -webkit-animation: line-square 1s ease infinite;
  329. animation: line-square 1s ease infinite;
  330. }
  331. .loader.line-square span:nth-child(1) {
  332. left: 0;
  333. -webkit-animation-delay: .13s;
  334. animation-delay: .13s;
  335. }
  336. .loader.line-square span:nth-child(2) {
  337. left: 1.3rem;
  338. -webkit-animation-delay: .26s;
  339. animation-delay: .26s;
  340. }
  341. .loader.line-square span:nth-child(3) {
  342. left: 2.6rem;
  343. -webkit-animation-delay: .39s;
  344. animation-delay: .39s;
  345. }
  346. .loader.line-square span:nth-child(4) {
  347. left: 3.9rem;
  348. -webkit-animation-delay: .52s;
  349. animation-delay: .52s;
  350. }
  351. .loader.line-square span:nth-child(5) {
  352. left: 5.2rem;
  353. -webkit-animation-delay: .65s;
  354. animation-delay: .65s;
  355. }
  356. @keyframes line-square {
  357. 0% {
  358. opacity: 1;
  359. transform: scale(1.2);
  360. -webkit-transform: scale(1.2);
  361. }
  362. 100% {
  363. opacity: .2;
  364. transform: scale(.2);
  365. -webkit-transform: scale(.2);
  366. }
  367. }
  368. @-webkit-keyframes line-square {
  369. 0% {
  370. opacity: 1;
  371. transform: scale(1.2);
  372. -webkit-transform: scale(1.2);
  373. }
  374. 100% {
  375. opacity: .2;
  376. transform: scale(.2);
  377. -webkit-transform: scale(.2);
  378. }
  379. }
  380. /*line-round*/
  381. .loader.line-round {
  382. width: 6rem;
  383. height: .8rem;
  384. }
  385. .loader.line-round span {
  386. position: absolute;
  387. top: 0;
  388. width: .8rem;
  389. height: .8rem;
  390. border-radius: 50%;
  391. display: inline-block;
  392. background: #1ABC9C;
  393. -webkit-animation: line-round 1s ease infinite;
  394. animation: line-round 1s ease infinite;
  395. }
  396. .loader.line-round span:nth-child(1) {
  397. left: 0;
  398. -webkit-animation-delay: .13s;
  399. animation-delay: .13s;
  400. }
  401. .loader.line-round span:nth-child(2) {
  402. left: 1.3rem;
  403. -webkit-animation-delay: .26s;
  404. animation-delay: .26s;
  405. }
  406. .loader.line-round span:nth-child(3) {
  407. left: 2.6rem;
  408. -webkit-animation-delay: .39s;
  409. animation-delay: .39s;
  410. }
  411. .loader.line-round span:nth-child(4) {
  412. left: 3.9rem;
  413. -webkit-animation-delay: .52s;
  414. animation-delay: .52s;
  415. }
  416. .loader.line-round span:nth-child(5) {
  417. left: 5.2rem;
  418. -webkit-animation-delay: .65s;
  419. animation-delay: .65s;
  420. }
  421. @keyframes line-round {
  422. 0% {
  423. opacity: 1;
  424. transform: scale(1.2);
  425. -webkit-transform: scale(1.2);
  426. }
  427. 100% {
  428. opacity: .2;
  429. transform: scale(.2);
  430. -webkit-transform: scale(.2);
  431. }
  432. }
  433. @-webkit-keyframes line-round {
  434. 0% {
  435. opacity: 1;
  436. transform: scale(1.2);
  437. -webkit-transform: scale(1.2);
  438. }
  439. 100% {
  440. opacity: .2;
  441. transform: scale(.2);
  442. -webkit-transform: scale(.2);
  443. }
  444. }
  445. /*line-bounce*/
  446. .loader.line-bounce {
  447. width: 6rem;
  448. height: 2.5rem;
  449. }
  450. .loader.line-bounce span {
  451. position: absolute;
  452. top: 0;
  453. width: .5rem;
  454. height: 2.5rem;
  455. border-radius: 5px;
  456. display: inline-block;
  457. background: #1ABC9C;
  458. -webkit-animation: line-bounce 1s ease infinite;
  459. animation: line-bounce 1s ease infinite;
  460. }
  461. .loader.line-bounce span:nth-child(1) {
  462. left: 0;
  463. -webkit-animation-delay: -.65s;
  464. animation-delay: -.65s;
  465. }
  466. .loader.line-bounce span:nth-child(2) {
  467. left: 1.3rem;
  468. -webkit-animation-delay: -.78s;
  469. animation-delay: -.78s;
  470. }
  471. .loader.line-bounce span:nth-child(3) {
  472. left: 2.6rem;
  473. -webkit-animation-delay: -.91s;
  474. animation-delay: -.91s;
  475. }
  476. .loader.line-bounce span:nth-child(4) {
  477. left: 3.9rem;
  478. -webkit-animation-delay: -.78s;
  479. animation-delay: -78s;
  480. }
  481. .loader.line-bounce span:nth-child(5) {
  482. left: 5.2rem;
  483. -webkit-animation-delay: -.65s;
  484. animation-delay: -.65s;
  485. }
  486. @keyframes line-bounce {
  487. 0% {
  488. transform: scaleY(1);
  489. }
  490. 50% {
  491. transform: scaleY(.3);
  492. }
  493. 100% {
  494. transform: scaleY(1);
  495. }
  496. }
  497. @-webkit-keyframes line-bounce {
  498. 0% {
  499. -webkit-transform: scaleY(1);
  500. }
  501. 50% {
  502. -webkit-transform: scaleY(.3);
  503. }
  504. 100% {
  505. -webkit-transform: scaleY(1);
  506. }
  507. }
  508. /*circle-spin*/
  509. .loader.circle-spin {
  510. border-radius: 50%;
  511. border: .2rem solid rgba(0, 0, 0, .05);
  512. width: 4rem;
  513. height: 4rem;
  514. box-sizing: content-box;
  515. }
  516. .loader.circle-spin .loader-placeholder {
  517. position: absolute;
  518. top: -.2rem;
  519. left: -.2rem;
  520. border-radius: 50%;
  521. border: .2rem solid transparent;
  522. border-top: .2rem solid #1ABC9C;
  523. width: 4rem;
  524. height: 4rem;
  525. box-sizing: content-box;
  526. -webkit-animation: circle-spin 1s ease infinite;
  527. animation: circle-spin 1s ease infinite;
  528. }
  529. @keyframes circle-spin {
  530. 0% {
  531. transform: rotate(0);
  532. }
  533. 100% {
  534. transform: rotate(360deg);
  535. }
  536. }
  537. @-webkit-keyframes circle-spin {
  538. 0% {
  539. -webkit-transform: rotate(0);
  540. }
  541. 100% {
  542. -webkit-transform: rotate(360deg);
  543. }
  544. }
  545. </style>
  546. </head>
  547. <body>
  548. <div>
  549. <div class="loader circle-line small">
  550. <span></span>
  551. <span></span>
  552. <span></span>
  553. <span></span>
  554. <span></span>
  555. <span></span>
  556. <span></span>
  557. <span></span>
  558. </div>
  559. <div class="loader circle-line-spin small">
  560. <div>
  561. <span></span>
  562. <span></span>
  563. <span></span>
  564. <span></span>
  565. <span></span>
  566. <span></span>
  567. <span></span>
  568. <span></span>
  569. </div>
  570. </div>
  571. <div class="loader circle-round small">
  572. <span></span>
  573. <span></span>
  574. <span></span>
  575. <span></span>
  576. <span></span>
  577. <span></span>
  578. <span></span>
  579. <span></span>
  580. </div>
  581. <div class="loader circle-round-fade small">
  582. <span></span>
  583. <span></span>
  584. <span></span>
  585. <span></span>
  586. <span></span>
  587. <span></span>
  588. <span></span>
  589. <span></span>
  590. </div>
  591. <div class="loader line-square small">
  592. <span></span>
  593. <span></span>
  594. <span></span>
  595. <span></span>
  596. <span></span>
  597. </div>
  598. <div class="loader line-round small">
  599. <span></span>
  600. <span></span>
  601. <span></span>
  602. <span></span>
  603. <span></span>
  604. </div>
  605. <div class="loader line-bounce small">
  606. <span></span>
  607. <span></span>
  608. <span></span>
  609. <span></span>
  610. <span></span>
  611. </div>
  612. <div class="loader circle-spin small">
  613. <div></div>
  614. </div>
  615. </div>
  616. </body>
  617. </html>


相信看了这些案例你已经掌握了方法,更多精彩请关注Gxl网其它相关文章!

相关阅读:

HTML5响应式banner制作教程

用H5制作水滴特效教程

HTML网页优化压缩的实现步骤

以上就是常见的几种loding效果实现的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行