Właściwość animation-duration

Właściwość animation-duration ustawia czas trwania animacji.

Składnia

cssselektor {
  animation-duration: czas w s lub ms;
}

Wartości

Wartość Opis
s Określa czas w sekundach (np. 3s).
ms Określa czas w milisekundach (np. 3ms). Jedna sekunda to 1000 milisekund.

Wartość domyślna: 0s.

Przykład

W tym przykładzie animacja będzie odtwarzana przez 3 sekundy:

html<div id="elem"></div>
css@keyframes move {
  from {
    margin-left: 0px;
  }
  to {
    margin-left: 400px;
  }
}

#elem {
  animation-duration: 3s;
  animation-name: move;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
  border: 1px solid black;
  width: 50px;
  height: 50px;
}

Результат:

Zobacz też