<style>
div {
border: 1px solid;
}
div .line {
width: 2px;
height: 2px;
background-color: red;
color: red;
border-radius: 2px;
}
#container{
width: 800px;
height:600px;
position: relative;
}
#div1 {
-webkit-animation: aaa 4s;
-webkit-animation-iteration-count: infinite;
}
#div2 {
position: absolute;
left: 500px;
-webkit-animation: bbb 4s;
-webkit-animation-direction: normal;
/*normal (每次从正方向开始)
animation-direction: reverse (每次从反方向开始)
animation-direction: alternate (正反往复)*/
-webkit-animation-iteration-count: infinite;
}
#div3 {
position: absolute;
top: 500px;
-webkit-animation: ccc 4s;
-webkit-animation-iteration-count: infinite;
}
#div4 {
position: absolute;
left: 0;
-webkit-animation: ddd 4s;
-webkit-animation-direction: normal;
-webkit-animation-iteration-count: infinite;
}
@-webkit-keyframes aaa
{
0% {
width: 2px;
}
25%,100% {
width: 500px;
}
}
@-webkit-keyframes bbb
{
0% {
}
25% {
height: 2px;
}
50%,100% {
height: 500px;
}
}
@-webkit-keyframes ccc
{
50% {
width: 2px;
left: 500px;
}
75%,100%{
width: 500px;
left: 0;
}
}
@-webkit-keyframes ddd
{
75% {
height: 2px;
top:498px;
}
100% {
height: 500px;
top:0px;
}
}
</style>
11111111
<br> 22222222222
<br> 33333333333
<br>
<div id="container">
<div id="div1" class="line">
</div>
<div id="div2" class="line"></div>
<div id="div3" class="line"></div>
<div id="div4" class="line"></div>
</div>