项目中使用的动画汇总
1、旋转木马
<!DOCTYPE html>
<html>
<head>
<style>
.stage {
perspective: 1200px;
}
.box {
position: relative;
height: 300px;
width: 300px;
margin: 200px auto;
transform-style: preserve-3d;
animation: rotate 8s infinite linear;
}
.item {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
line-height: 300px;
text-align: center;
font-size: 100px;
border: 1px solid red;
}
.item-1 {
transform: translateZ(260px);
background-color: rgba(255, 0, 0, .5);
}
.item-2 {
transform: rotateY(60deg) translateZ(260px);
background-color: rgba(0, 255, 0, .5);
}
.item-3 {
transform: rotateY(120deg) translateZ(260px);
background-color: rgba(0, 0, 255, .5);
}
.item-4 {
transform: rotateY(180deg) translateZ(260px);
background-color: rgba(255, 255, 0, .5);
}
.item-5 {
transform: rotateY(240deg) translateZ(260px);
background-color: rgba(255, 0, 255, .5);
}
.item-6 {
transform: rotateY(300deg) translateZ(260px);
background-color: rgba(0, 255, 255, .5);
}
.item-a {
transform: translateZ(150px) translateY(-100px);
background-color: rgba(0, 255, 255, .5);
}
.item-b {
transform: rotateY(90deg) translateZ(150px) translateY(-100px);
background-color: rgba(0, 255, 255, .5);
}
.item-c {
transform: rotateY(180deg) translateZ(150px) translateY(-100px);
background-color: rgba(0, 255, 255, .5);
}
.item-d {
transform: rotateY(270deg) translateZ(150px) translateY(-100px);
background-color: rgba(0, 255, 255, .5) translateY(-100px);
}
@keyframes rotate {
from {
transform: rotateY(360deg);
}
to {
transform: rotateY(0deg);
}
}
</style>
</head>
<body>
<div class="stage">
<div class="box">
<div class="item item-1">1</div>
<div class="item item-2">2</div>
<div class="item item-3">3</div>
<div class="item item-4">4</div>
<div class="item item-5">5</div>
<div class="item item-6">6</div>
<div class="item item-a">A</div>
<div class="item item-b">B</div>
<div class="item item-c">C</div>
<div class="item item-d">D</div>
</div>
</div>
<div class="tetst">123</div>
</body>
</html>
2、下拉列表
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<style>
* {
list-style: none;
padding: 0;
margin: 0;
}
@keyframes show2 {
from {
height: 0px;
}
to {
height: 200px;
}
}
.box {
margin-top: 10px;
position: relative;
width: 120px;
padding-right: 20px;
background-color: pink;
}
.box:hover ul {
height: 200px;
animation: show2 .5s forwards;
/* transition: height 2s ; */
}
.box:hover::after{
top: 15px;
transform: rotate(225deg);
transition: transform .5s ;
}
.box::after{
position: absolute;
right: 10px;
top: 20px;
content:"" ;
display: block;
width: 0;
height: 0;
transform: rotate(45deg);
border-bottom: 10px solid transparent;
border-left: 10px solid green;
}
ul::-webkit-scrollbar {
width: 0;
}
p {
height: 40px;
line-height: 40px;
text-align: center;
}
ul {
position: absolute;
top: 100%;
left: 0;
width: 100%;
height: 0;
background-color: red;
z-index: 10;
max-height: 200px;
overflow-y: auto;
}
li {
height: 30px;
width: 100%;
line-height: 30px;
text-align: center;
background-color: grey;
color: #fff;
}
li:hover {
background-color: green;
color: #fff;
}
</style>
<body>
<div class="box">
<p>请选择</p>
<ul>
<li>西游记1</li>
<li>红楼梦</li>
<li>三国演义</li>
<li>水浒传</li>
<li>西游记1</li>
<li>红楼梦</li>
<li>三国演义</li>
<li>水浒传</li>
</ul>
</div>
<div class="box">
<p>请选择你的书</p>
<ul>
<li>西游记1</li>
<li>红楼梦</li>
<li>三国演义</li>
<li>水浒传</li>
</ul>
</div>
</body>
</html>