我尝试制作动画效果,框来自容器外部,文本出现在该框之后。
当我在文本动画中添加延迟时,它会中断,如何同步两个动画?
请帮帮我。 向我询问更多详细信息...
@keyframes animText {
0% {
max-width: 0;
visibility: hidden;
}
100% {
max-width: 100%;
visibility: visible;
}
}
@keyframes animBox {
0% {
right: 100%;
visibility: hidden;
}
100% {
right: 0;
visibility: visible;
}
}
#box {
position: relative;
overflow: hidden;
padding: 10px;
width: 220px;
height: 75px;
background-color: #343434;
display: flex;
}
.redbox {
background-color: crimson;
opacity: 0.95;
width: 74px;
height: 74px;
max-width: 75px;
flex: 1 0;
position: relative;
animation: animBox 2s cubic-bezier(0,0,1,1);
}
p {
font-size: 50px;
line-height: 0.75em;
color: #fff;
margin: 0;
overflow: hidden;
flex: 1 0;
animation: animText 3s cubic-bezier(0,0,1,1) 1s;
}
<div id="box">
<p>Some Text</p>
<div class="redbox"></div>
</div>
答案 0 :(得分:1)
兄弟。
@keyframes animText {
0% {
max-width: 0;
visibility: hidden;
}
33% {
max-width: 0%;
visibility: visible;
}
100% {
max-width: 100%;
visibility: visible;
}
}
@keyframes animBox {
0% {
right: 100%;
visibility: hidden;
}
100% {
right: 0;
visibility: visible;
}
}
#box {
position: relative;
overflow: hidden;
padding: 10px;
width: 220px;
height: 75px;
background-color: #343434;
display: flex;
}
.redbox {
background-color: crimson;
opacity: 0.95;
width: 74px;
height: 74px;
max-width: 75px;
flex: 1 0;
position: relative;
animation: animBox 1s cubic-bezier(0, 0, 1, 1);
}
p {
font-size: 50px;
line-height: 0.75em;
color: #fff;
margin: 0;
overflow: hidden;
flex: 1 0;
animation: animText 2s cubic-bezier(0, 0, 1, 1);
}
<div id="box">
<p>Some Text</p>
<div class="redbox"></div>
</div>