有沒有辦法跳到css影片中的特定時間?例如:如果我們有一個 div 在 10 秒內從左向右移動,用戶將時間更改為 5 并且影片跳轉到第 5 秒并繼續播放。
uj5u.com熱心網友回復:
改變animation-delay會做到這一點。
當您將其更改為負值時,它將向前跳轉。
const selectElement = document.querySelector('.number');
selectElement.addEventListener('change', (event) => {
const result = document.querySelector('.some-div');
result.style.animationDelay = `${event.target.value}s`;
});
.some-div {
width: 100px;
height: 100px;
background-color: red;
animation-name: example;
animation-duration: 20s;
animation-delay: 0;
}
@keyframes example {
from {
transform: translateX(0px);
}
to {
transform: translateX(400px);
}
}
<div class="some-div"></div>
<input type="number" class="number" />
<br/>
change the value in the input
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/440954.html
