我有以下代码。
#mf-loader-container {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 500px;
height: 30px;
}
.mf-loader-circle {
position: absolute;
height: 30px;
width: 30px;
border-radius: 50%;
border: 2px solid #03C9A9;
top: -15px;
background: white;
text-align: center;
line-height: 30px;
color: #03C9A9;
}
.mf-loader-text {
position: absolute;
width: 150px;
top: 20px;
}
#one-text {
left: -10px;
-webkit-animation: cl 3s;
}
#two-text {
left: 200px;
-webkit-animation: cl 3s;
-webkit-animation-delay: 2s;
-webkit-animation-fill-mode: forwards;
color: rgba(1, 1, 1, 0);
}
#three-text {
left: 480px;
-webkit-animation: cl 3s;
-webkit-animation-delay: 3s;
-webkit-animation-fill-mode: forwards;
color: rgba(1, 1, 1, 0);
}
@-webkit-keyframes cl {
from {
color: rgba(1, 1, 1, 0);
}
to {
color: rgba(1, 1, 1, 1);
}
}
#two {
left: 240px;
}
#three {
left: 490px;
}
#mf-loader {
width: 100%;
height: 3px;
background: #03C9A9;
position: absolute;
-webkit-animation: mymove 5s;
/* Chrome, Safari, Opera */
animation: mymove 5s;
border-radius: 3px;
}
/* Chrome, Safari, Opera */
@-webkit-keyframes mymove {
0% {
width: 0px;
}
50% {
width: 50%;
}
100% {
width: 100%;
}
}
/* Standard syntax */
@keyframes mymove {
0% {
width: 0px;
}
50% {
width: 50%;
}
100% {
width: 100%;
}
}
<div id="mf-loader-container">
<div id="mf-loader">
<div class="mf-loader-circle" id="one">
1
</div>
<div class="mf-loader-circle" id="two">
2
</div>
<div class="mf-loader-circle" id="three">
3
</div>
<div class="mf-loader-text" id="one-text">
Each day will be better than last.
<br>This one especially
</div>
<div class="mf-loader-text" id="two-text">
Subscribing .. Thank you for subscribing. We appreciate it!
</div>
<div class="mf-loader-text" id="three-text">
DONE
</div>
</div>
</div>
这是一个类似动画的结帐操作,仅使用CSS完成。我试图在文本显示后更改圈子的内容以勾选✓
- 是否有任何方法可以使用css中的内容标记更改内容。
答案 0 :(得分:2)
将内容(1,2,3个数字)更改为:after
个伪元素并在其中设置内容。然后,将其应用于每个圆圈。有了这个,您可以通过更改content:"";
将它们包含在动画中
改变&#34;检查&#34;无论你需要什么。
.mf-loader-circle:after {
position: absolute;
width: 100%;
height: 100%;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
#one:after {
content: "1";
-webkit-animation: check1 3s;
-webkit-animation-fill-mode: forwards;
}
#two:after {
content: "2";
-webkit-animation: check2 3s;
-webkit-animation-delay: 2s;
-webkit-animation-fill-mode: forwards;
}
#three:after {
content: "3";
-webkit-animation: check3 3s;
-webkit-animation-delay: 3s;
-webkit-animation-fill-mode: forwards;
}
@-webkit-keyframes check1 {
from {
content: "1";
}
to {
content: "check";
}
}
@-webkit-keyframes check2 {
from {
content: "2";
}
to {
content: "check";
}
}
@-webkit-keyframes check3 {
from {
content: "3";
}
to {
content: "check";
}
}
#mf-loader-container {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 500px;
height: 30px;
}
.mf-loader-circle {
position: absolute;
height: 30px;
width: 30px;
border-radius: 50%;
border: 2px solid #03C9A9;
top: -15px;
background: white;
text-align: center;
line-height: 30px;
color: #03C9A9;
}
.mf-loader-text {
position: absolute;
width: 150px;
top: 20px;
}
#one-text {
left: -10px;
-webkit-animation: cl 3s;
}
#two-text {
left: 200px;
-webkit-animation: cl 3s;
-webkit-animation-delay: 2s;
-webkit-animation-fill-mode: forwards;
color: rgba(1, 1, 1, 0);
}
#three-text {
left: 480px;
-webkit-animation: cl 3s;
-webkit-animation-delay: 3s;
-webkit-animation-fill-mode: forwards;
color: rgba(1, 1, 1, 0);
}
@-webkit-keyframes cl {
from {
color: rgba(1, 1, 1, 0);
}
to {
color: rgba(1, 1, 1, 1);
}
}
#two {
left: 240px;
}
#three {
left: 490px;
}
#mf-loader {
width: 100%;
height: 3px;
background: #03C9A9;
position: absolute;
-webkit-animation: mymove 5s;
/* Chrome, Safari, Opera */
animation: mymove 5s;
border-radius: 3px;
}
/* Chrome, Safari, Opera */
@-webkit-keyframes mymove {
0% {
width: 0px;
}
50% {
width: 50%;
}
100% {
width: 100%;
}
}
/* Standard syntax */
@keyframes mymove {
0% {
width: 0px;
}
50% {
width: 50%;
}
100% {
width: 100%;
}
}
&#13;
<div id="mf-loader-container">
<div id="mf-loader">
<div class="mf-loader-circle" id="one">
</div>
<div class="mf-loader-circle" id="two">
</div>
<div class="mf-loader-circle" id="three">
</div>
<div class="mf-loader-text" id="one-text">
Each day will be better than last.
<br>This one especially
</div>
<div class="mf-loader-text" id="two-text">
Subscribing .. Thank you for subscribing. We appreciate it!
</div>
<div class="mf-loader-text" id="three-text">
DONE
</div>
</div>
</div>
&#13;
:after
伪元素。.mf-loader-circle:after {
position:absolute;
width:100%;
height:100%;
left:50%;
top:50%;
transform:translate(-50%, -50%);
}
在这里,我使用2D变换将数字定位在中心position:absolute;
使用元素&#39;将每个content:"";
属性设置为必要的数字。的ID。
为不同的数字创建动画,例如:
#one:after {
content:"1";
-webkit-animation: check1 3s;
-webkit-animation-fill-mode: forwards;
}
@-webkit-keyframes check1{
from {
content:"1";
}
to {
content:"check";
}
}
注意:添加相应的供应商前缀。
答案 1 :(得分:1)
您可以使用:before
使用content: 'number';
分配每个号码。然后,您可以通过在50%
将颜色更改为白色,然后为其指定复选标记值,在关键帧中平滑地设置检查过渡动画。
对于此解决方案,您只需要定义1个关键帧动画。
CSS更改
content
显示您的数字而不是html内部。设置关键帧动画,延迟(第一个除外)和填充模式。
.mf-loader-circle#two:before {
content: '2';
animation: changeLetter 2s;
animation-delay: 1.5s;
animation-fill-mode: forwards;
}
将颜色更改为白色,然后为其指定复选标记。
@keyframes changeLetter {
50% {
color: white;
}
100% {
content: "\2713";
}
}
#mf-loader-container {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 500px;
height: 30px;
}
.mf-loader-circle {
position: absolute;
height: 30px;
width: 30px;
border-radius: 50%;
border: 2px solid #03C9A9;
top: -15px;
background: white;
text-align: center;
line-height: 30px;
color: #03C9A9;
}
.mf-loader-circle#one:before {
content: '1';
-webkit-animation: changeLetter 2s;
/* Chrome, Safari, Opera */
animation: changeLetter 2s;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
}
.mf-loader-circle#two:before {
content: '2';
-webkit-animation: changeLetter 2s;
/* Chrome, Safari, Opera */
animation: changeLetter 2s;
-webkit-animation-delay: 1.5s;
animation-delay: 1.5s;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
}
.mf-loader-circle#three:before {
content: '3';
-webkit-animation: changeLetter 2s;
/* Chrome, Safari, Opera */
animation: changeLetter 2s;
-webkit-animation-delay: 3s;
animation-delay: 3s;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
}
.mf-loader-text {
position: absolute;
width: 150px;
top: 20px;
}
#one-text {
left: -10px;
-webkit-animation: cl 3s;
}
#two-text {
left: 200px;
-webkit-animation: cl 3s;
-webkit-animation-delay: 2s;
-webkit-animation-fill-mode: forwards;
color: rgba(1, 1, 1, 0);
}
#three-text {
left: 480px;
-webkit-animation: cl 3s;
-webkit-animation-delay: 3s;
-webkit-animation-fill-mode: forwards;
color: rgba(1, 1, 1, 0);
}
@-webkit-keyframes cl {
from {
color: rgba(1, 1, 1, 0);
}
to {
color: rgba(1, 1, 1, 1);
}
}
#two {
left: 240px;
}
#three {
left: 490px;
}
#mf-loader {
width: 100%;
height: 3px;
background: #03C9A9;
position: absolute;
-webkit-animation: mymove 5s;
/* Chrome, Safari, Opera */
animation: mymove 5s;
border-radius: 3px;
}
/* Chrome, Safari, Opera */
@-webkit-keyframes mymove {
0% {
width: 0px;
}
50% {
width: 50%;
}
100% {
width: 100%;
}
}
/* Standard syntax */
@keyframes mymove {
0% {
width: 0px;
}
50% {
width: 50%;
}
100% {
width: 100%;
}
}
@-webkit-@keyframes changeLetter {
50% {
color: white;
}
100% {
content: "\2713";
}
}
@keyframes changeLetter {
50% {
color: white;
}
100% {
content: "\2713";
}
}
&#13;
<div id="mf-loader-container">
<div id="mf-loader">
<div class="mf-loader-circle" id="one">
</div>
<div class="mf-loader-circle" id="two">
</div>
<div class="mf-loader-circle" id="three">
</div>
<div class="mf-loader-text" id="one-text">
Each day will be better than last.
<br>This one especially
</div>
<div class="mf-loader-text" id="two-text">
Subscribing .. Thank you for subscribing. We appreciate it!
</div>
<div class="mf-loader-text" id="three-text">
DONE
</div>
</div>
</div>
&#13;
<强> JSFiddle 强>