Die @keyframes-opdrag
Die @keyframes-opdrag spesifiseer die sleutelframe
vir 'n animasie. 'n Sleutelframe verteenwoordig verskillende
eienskappe van ons CSS-element, byvoorbeeld posisie,
grootte, kleur, ens., wat op 'n gespesifiseerde tydstip op die
element toegepas word.
Sintaksis
@keyframes animasienaam {
sleutelframe
}
Voorbeeld
Spesifiseer die sleutelframe:
<div id="elem"></div>
@keyframes anim {
from {
margin-left: 0px;
}
to {
margin-left: 400px;
}
}
#elem {
animation: anim 3s infinite;
border: 1px solid black;
width: 50px;
height: 50px;
}
:
Voorbeeld
Kom ons beweeg nou ons vierkant van bo na onder met behulp van animasie:
<div id="elem"></div>
@keyframes anim {
from {
margin-top: 0%;
}
to {
margin-top: 10%;
}
}
#elem {
animation: anim 2s infinite;
border: 1px solid black;
width: 50px;
height: 50px;
}
:
Voorbeeld
Kom ons vergroot die wydte van ons figuur met behulp van animasie deur sleutelpunte in persentasies te spesifiseer:
<div id="elem"></div>
@keyframes anim {
from {
width: 10%;
}
to {
width: 40%;
}
}
#elem {
animation: anim 2s infinite;
border: 1px solid black;
width: 50px;
height: 50px;
}
:
Voorbeeld
Kom ons verander nou die deursigtigheid van ons figuur:
<div id="elem"></div>
@keyframes anim {
from {
background-color: #467CBC;
}
to {
background-color: #C2DDFD;
}
}
#elem {
animation: anim 2s infinite;
border: 1px solid black;
width: 50px;
height: 50px;
}
:
Sien ook
-
alle eienskappe vir CSS-animasie
animation-name,animation-duration,animation-delay,animation-timing-function,animation-iteration-count,animation-direction,animation-fill-mode,animation-play-state,keyframes -
transition- gladde oorgange (animasie by wys op element)