CSS写动画

2019-04-02  本文已影响0人  徐辉英

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>loading</title>

<style type="text/css">

.box{

width: 620px;

height: 400px;

border: 3px solid #000;

margin: 0 auto;

}

.red,.green,.pink,.purple,.blue{

width: 100px;

height: 150px;

background-color: red;

float: left;

margin-left: 20px;

margin-top: 110px;

transform: scaleY(0.5);

transition: all 1s ease;

animation: moving 0.7s ease 1s infinite alternate both;

}

.box:hover{

animation-play-state: running;

}

.green{

background-color: green;

transition: all 1s ease;

animation: moving 1s ease 1s infinite alternate both;

}

.pink{

background-color: pink;

transition: all 1s ease;

animation: moving 1.4s ease 1s infinite alternate both;

}

.purple{

background-color: purple;

transition: all 1s ease;

animation: moving 1.7s ease 1s infinite alternate both;

}

.blue{

background-color: skyblue;

transition: all 1s ease;

animation: moving 2s ease 1s infinite alternate both;

}

@keyframes moving{

from{

height: 150px;

}

to{

height: 50px;

}

}

</style>

</head>

<body>

<div class="box">

<div class="red"></div>

<div class="green"></div>

<div class="pink"></div>

<div class="purple"></div>

<div class="blue"></div>

</div>

</body>

</html>

上一篇 下一篇

猜你喜欢

热点阅读