使用 css 的 animation ,可以做一个转圈的 loading 图,省去了使用 gif 图的麻烦。
为了力求精简,以下 css 样式都是集成在一个类上,
.loading{ display: inline-block; height: 10px; width: 10px; border-radius: 50%; border: 2px solid #999; border-bottom-color: transparent; -webkit-animation: loading 0.75s linear infinite; animation: loading 0.75s linear infinite; // 位置相关 margin: 6px; vertical-align: middle; } @-webkit-keyframes loading { 0% { -webkit-transform: rotate(0deg); } 50% { -webkit-transform: rotate(180deg); } 100% { -webkit-transform: rotate(360deg); } } @keyframes loading { 0% { -webkit-transform: rotate(0deg); } 50% { -webkit-transform: rotate(180deg); } 100% { -webkit-transform: rotate(360deg); } }
如下:
或:
.dot{ display: block; width: 32px; height: 32px; position: relative; margin: 10px auto; } .dot::before,.dot::after{ content: ‘‘; display: block; width: 50%; height: 50%; border-radius: 50%; background: #98bff6; position: absolute; top: 50%; left: 50%; } .dot::before{ opacity: 0.6; transform: scale(2); animation: bigDot 2s infinite; } .dot::after{ opacity: 0.4; transform: scale(0.1); animation: smallDot 2s infinite; } @keyframes bigDot { 0% { transform: scale(2) } 50% { transform: scale(0) } 100% { transform: scale(2) } } @keyframes smallDot { 0% { transform: scale(0) } 50% { transform: scale(2) } 100% { transform: scale(0) } }
如下:
-- end --
原文:https://www.cnblogs.com/_error/p/10532081.html