导航

萌即是正义!时不时分享一些ACG活动记录与有趣代码的小站!

侧边栏
最新评论
广树
2024-10-16 12:24
@橘夜庭:未来能成为聊天的谈资
广树
2024-10-16 12:24
@MoeNya:欢迎!
MoeNya
2024-10-16 11:03
来了!!!!!!!ヾ(≧∇≦*)ゝ
橘夜庭
2024-10-15 21:30
好有趣的圣地巡游经历(☆ω☆)
广树
2024-10-15 20:41
@apple:是啊,都不知道为什么就在国内火了。
正在攻略

e54e3ae78936587d51e4b180673cb495.png

logo_kai.jpg


PSN奖杯卡

PSN奖杯卡

赞助商广告

炼金瓶Loading效果

作者:广树时间:2018-09-11 13:49:54分类:CSS/HTML

想要给抽卡增加了一个延时Loading效果,用于有时候网络不好的时候给与提示。

然后偶然的一次机会,在<codepen>上看到了一个炼金瓶的Loading效果,甚是喜欢,于是想直接拿过来用,但是却遇到了很多问题。

于是经过一番改造,将其改造成了更佳平滑的瓶子和能够适应各种背景色。(其实就是瓶子由CSS绘制变成了图片,气泡和波浪没怎么修改)

效果预览:

炼金中...


然后就是代码部分了。

CSS:

.jar_loading {
	position: relative;
	z-index: 1;
}
.jar_loading_body {
	color: #ccc;
	padding: 0;
	margin: 0;
	text-align: center;
}
.jar_loading_body * {
	box-sizing: border-box;
	-moz-box-sizing: border-box;
	-webkit-box-sizing: border-box;
}
.jar_loading_box {
	position: relative;
	width: 200px;
	margin: 100px auto 0;
	text-align: center;
	padding-top: 40px;
}
.jar_loading_bg {
	background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAABwCAMAAACpQZdgAAAA1VBMVEX///8AAADJycrk5eXw8PDJycr////Jysvp6enJycrLzMz09PX+/v7Ky8vU1dXJycrJycrNzs7Oz8/Q0NHJycrJycrJycrJysvMzM3JycrR0tLJycrV1dbJycrJycrJycrJycr5+fnJycrb29zJycrJycrS0tPJycrJycrJysvNzc7JycrJycrJycrJycrc3d3e3t/g4eHi4+Pt7e74+PjJycrQ0dHx8fH7+/vJycrJycrW1tfJycrX2N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W3Fv+yuFBVXtCVIaRrceU0DCsvaaXlhXZs2WtFLC2aeXDNOHN2Id+MXLU0PbC048+GBd5ajqKV1hDUyZHyRIVha+taq1IFLs1jhnEJVCtvLeM6OhjT5KGXe2qA3tmxQlzVgbR22JTTQH21c/FZ8XXgUtsfvgR0v7LPutYeA2RmyX1GMcsAjO19l8xOEcC4W+yAF3cGQNE5ZDXujFWAXOksue33npVyAOrYOXShb38fEKa6qam2/EddatOUqxI2+G4f9YWjW73gMcPNFNqpUqpdyLgGj11UuzG+y6z8r7dEdfvVX8X85LOulfCrRe9CJ0y/8IpVP9FSdvcbhjbR7CHfGkMAAAAASUVORK5CYII=');
	background-position: bottom center;
	background-repeat: no-repeat;
	position: absolute;
	left: 0;
	right: 0;
	top: 0;
	bottom: 0;
	z-index: 2;
}
.jar_loading .bubble_loading {
	width: 10px;
	height: 10px;
	position: absolute;
	background-color: #35EEFB;
	opacity: 0.4;
	left: 92px;
	z-index: 8;
	top: 40px;
	-moz-border-radius: 100%;
	-webkit-border-radius: 100%;
	border-radius: 100%;
	-moz-animation: buble 2s linear 1s infinite;
	-webkit-animation: buble 2s linear 1s infinite;
	animation: buble 2s linear 1s infinite;
}
.jar_loading .bubble_loading + .bubble_loading {
	left: 90px;
	top: 42px;
	width: 15px;
	height: 15px;
	-moz-animation-duration: 3s;
	-webkit-animation-duration: 3s;
	animation-duration: 3s;
}
.jar_loading .base_loading {
	margin: auto;
	width: 90px;
	height: 72px;
	-moz-border-radius: 50%;
	-webkit-border-radius: 50%;
	border-radius: 50%;
	overflow: hidden;
	position: relative;
	z-index: 5;
	border: 2px solid rgba(255,255,255,0);
}
.jar_loading .base_loading .bubble_loading {
	left: 15px;
	top: 40px;
	-moz-animation: bounce 2.3s linear 0s infinite alternate;
	-webkit-animation: bounce 2.3s linear 0s infinite alternate;
	animation: bounce 2.3s linear 0s infinite alternate;
}
.jar_loading .base_loading .bubble_loading + .bubble_loading {
	left: 64px;
	top: 40px;
	-moz-animation-duration: 3s;
	-webkit-animation-duration: 3s;
	animation-duration: 3s;
}
.jar_loading .liquid_loading {
	height: 30px;
	background-color: #35EEFB;
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
}
.jar_loading .wave_loading {
	width: 60px;
	height: 20px;
	position: absolute;
	background-color: #35EEFB;
	left: 0;
	top: 37px;
	-moz-animation: wave 1s linear infinite alternate;
	-webkit-animation: wave 1s linear infinite alternate;
	animation: wave 1s linear infinite alternate;
	-moz-border-radius: 50%;
	-webkit-border-radius: 50%;
	border-radius: 50%;
}
.jar_loading .wave_loading + .wave_loading {
	left: auto;
	right: 0;
}
.jar_loading_text {
	margin: 8px 0;
}
 @-moz-keyframes wave {
 from {
 -moz-transform: translateX(100px);
 transform: translateX(100px);
}
 to {
 -moz-transform: translateX(-100px);
 transform: translateX(-100px);
}
}
@-webkit-keyframes wave {
 from {
 -webkit-transform: translateX(100px);
 transform: translateX(100px);
}
 to {
 -webkit-transform: translateX(-100px);
 transform: translateX(-100px);
}
}
@keyframes wave {
 from {
 -moz-transform: translateX(100px);
 -ms-transform: translateX(100px);
 -webkit-transform: translateX(100px);
 transform: translateX(100px);
}
 to {
 -moz-transform: translateX(-100px);
 -ms-transform: translateX(-100px);
 -webkit-transform: translateX(-100px);
 transform: translateX(-100px);
}
}
@-moz-keyframes bounce {
 0% {
 -moz-transform: translate(5px, 15px);
 transform: translate(5px, 15px);
}
 50% {
 -moz-transform: translate(0, -15px);
 transform: translate(0, -15px);
}
 100% {
 -moz-transform: translate(-5px, -31px);
 transform: translate(-5px, -31px);
 opacity: 1;
}
}
@-webkit-keyframes bounce {
 0% {
 -webkit-transform: translate(5px, 15px);
 transform: translate(5px, 15px);
}
 50% {
 -webkit-transform: translate(0, -15px);
 transform: translate(0, -15px);
}
 100% {
 -webkit-transform: translate(-5px, -31px);
 transform: translate(-5px, -31px);
 opacity: 1;
}
}
@keyframes bounce {
 0% {
 -moz-transform: translate(5px, 15px);
 -ms-transform: translate(5px, 15px);
 -webkit-transform: translate(5px, 15px);
 transform: translate(5px, 15px);
}
 50% {
 -moz-transform: translate(0, -15px);
 -ms-transform: translate(0, -15px);
 -webkit-transform: translate(0, -15px);
 transform: translate(0, -15px);
}
 100% {
 -moz-transform: translate(-5px, -31px);
 -ms-transform: translate(-5px, -31px);
 -webkit-transform: translate(-5px, -31px);
 transform: translate(-5px, -31px);
 opacity: 1;
}
}
@-moz-keyframes buble {
 0% {
 -moz-transform: translate(3px, 10px);
 transform: translate(3px, 10px);
}
 25% {
 -moz-transform: translate(0, 0px);
 transform: translate(0, 0px);
}
 50% {
 -moz-transform: translate(-1px, -25px);
 transform: translate(-3px, -25px);
}
 75% {
 -moz-transform: translate(0, -50px);
 transform: translate(0, -50px);
 opacity: 1;
}
 100% {
 -moz-transform: translate(3px, -100px);
 transform: translate(3px, -100px);
 opacity: 0;
}
}
@-webkit-keyframes buble {
 0% {
 -webkit-transform: translate(3px, 10px);
 transform: translate(3px, 10px);
}
 25% {
 -webkit-transform: translate(0, 0px);
 transform: translate(0, 0px);
}
 50% {
 -webkit-transform: translate(-3px, -25px);
 transform: translate(-3px, -25px);
}
 75% {
 -webkit-transform: translate(0, -50px);
 transform: translate(0, -50px);
 opacity: 1;
}
 100% {
 -moz-transform: translate(3px, -100px);
 -ms-transform: translate(3px, -100px);
 -webkit-transform: translate(3px, -100px);
 transform: translate(3px, -100px);
 opacity: 0;
}
}
@keyframes buble {
 0% {
 -moz-transform: translate(3px, 10px);
 -ms-transform: translate(3px, 10px);
 -webkit-transform: translate(3px, 10px);
 transform: translate(3px, 10px);
}
 25% {
 -moz-transform: translate(0, 0px);
 -ms-transform: translate(0, 0px);
 -webkit-transform: translate(0, 0px);
 transform: translate(0, 0px);
}
 50% {
 -moz-transform: translate(-1px, -25px);
 -ms-transform: translate(-1px, -25px);
 -webkit-transform: translate(-3px, -25px);
 transform: translate(-3px, -25px);
}
 75% {
 -moz-transform: translate(0, -50px);
 -ms-transform: translate(0, -50px);
 -webkit-transform: translate(0, -50px);
 transform: translate(0, -50px);
 opacity: 1;
}
 100% {
 -moz-transform: translate(3px, -100px);
 -ms-transform: translate(3px, -100px);
 -webkit-transform: translate(3px, -100px);
 transform: translate(3px, -100px);
 opacity: 0;
}
}


HTML:

<div class="jar_loading_body">
    <div class="jar_loading_box">
    	<div class="jar_loading_bg"></div>
        <div class="jar_loading">
          <div class="base_loading">
            <div class="liquid_loading"> </div>
            <div class="wave_loading"></div>
            <div class="wave_loading"></div>
            <div class="bubble_loading"></div>
            <div class="bubble_loading"></div>
          </div>
          <div class="bubble_loading"></div>
          <div class="bubble_loading"></div>
        </div>
    </div>
    <p class="jar_loading_text">炼金中...</p>
</div>