<div class="info">
<p>За допомогою універсальної властивості <code>animation-delay</code> ми можемо встановити час очікування перед запуском циклу анімації.</p>
<p>Нижче, показаний приклад такої анімації. Ми визначили таймер на 4 секунди.</p>
</div>
<div id="time">4s</div>
<div class="wrapper">
<span id="text">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span>
</div>
* {
box-sizing: border-box;
}
body {
font-family: monospace;
font-size: 15px;
overflow: hidden;
line-height: 1.45;
}
.info {
padding: 6px;
}
code {
font-weight: 700;
color: #444;
border-bottom: 2px solid #666;
}
.wrapper {
background-color: #dcdcdc;
}
#text {
margin-top: 0;
display: block;
animation: anim 1.75s linear 10s infinite alternate none paused;
font-weight: 700;
padding: 8px 0;
text-align: center;
/*animation-delay: 2s;
animation-name: anim;
animation-play-state: paused;
animation-duration: .8s;
animation-iteration-count: infinite;
animation-timing-function: linear;*/
}
@keyframes anim {
0% { margin-top: 0; }
50% { margin-top: 50px; }
100% { margin-top: 0; }
}
function startTimer() {
var timer = 10, seconds;
var showTime = setInterval(function () {
seconds = parseInt(timer % 60, 10);
document.getElementById('time').innerText = seconds + 's';
if (--timer < 0) {
clearInterval(showTime);
}
}, 1000);
}
window.onload = function() {
startTimer();
document.getElementById('text').style.animationPlayState = 'running';
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.