1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <MetaCharSet= "Utf-8">5 <title></title>6 <Linkrel= "stylesheet"type= "Text/css"href= "Style.css">7 </Head>8 <Body>9 <Div></Div>Ten </Body> One </HTML>
1 Div{2 width:300px;3 Height:200px;4 Background-color:Red;5 Animation-name:myanimation;6 animation-duration:3s;7 animation-timing-function:Ease;8 Animation-delay:1s;9 Animation-iteration-count:3/*Infinite*/;/*Infinite always play*/Ten animation-direction:Alternate;/*Normal*/;/*Specifies the sequence of playback for the next cycle of the animation, that is, the order of the odd number of plays: normal default order play, alternate reverse play*/ One Animation-fill-mode:both;/*By default None, the animation will stop in its original state. The forwards property value causes the animation to stop at the last frame state. Backwards will immediately switch to frame 1th and perform the Animation-delay delay. Both applies both the forwards and backwards property values. */ A Animation: ;/*all specific property values can be set in the shorthand property name, separated by a space between each property value*/ -} - @keyframes myanimation{ the /*from{ - width:150px; - height:100px; - Background-color:blue; + } - to{ + width:200px; A height:150px; at Background-color:green; - }*/ - 0%{ - Margin-left:20px; - Background-color:Pink; -} in 20%{ - Margin-left:100px; to Background-color:Orange; +} - 40%{ the Margin-top:100px; * Background-color:Yellow; $}Panax Notoginseng 60%{ - Margin-top:200px; the Background-image:Grey; +} A 100%{ the Margin-right:300px; + Margin-top:150px; - background:Green; $} $ }
"CSS3" animation animation-keyframes keyframes