我正在使用CSS的content
属性在HTML标签之前添加内容。
span::before {
content: 'content that needs a delay';
}
<span></span>
span::before {
content: 'content that needs a delay';
margin-top: 25px;
font-size: 21px;
text-align: center;
animation: fadein 4s;
}
@keyframes fadein {
from {
opacity:0;
}
to {
opacity:1;
}
}
<span></span>
css-animation
。
span::before {
content: 'content that needs a delay';
opacity: 0;
animation: 2s fadeIn;
animation-fill-mode: forwards;
transition: opacity 1.5s;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
<span></span>
animation-fill-mode:forwards
或其他方式,在动画完成后保留内容,否则内容将被隐藏。
span::before {
content: 'content that needs a delay';
-webkit-animation:0.6s opc forwards;
opacity:0;
transition:opacity 0.6s;
}
@-webkit-keyframes opc{
from{
opacity:0;
}
to{
opacity:1;
}
}
<span></span>
overflow: hidden
或者 transform: translateX
来将 max-width
从0动画到一个很大的值,或者将一个很大的值动画到0。 - Denis Sheremet