美文网首页
CSS写动画

CSS写动画

作者: 徐辉英 | 来源:发表于2019-04-02 19:25 被阅读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>

相关文章

网友评论

      本文标题:CSS写动画

      本文链接:https://www.haomeiwen.com/subject/rfdnbqtx.html