transition
CSS
<style>
*{
margin: 0;
padding: 0;
}
body{
background-color: #000;
}
.sec{
width: 600px;
height: 150px;
border: 1px solid #fff;
margin: 150px auto;
position: relative;
border-radius: 10px;
}
.sec ul{
width: 600px;
height: 150px;
position: absolute;
overflow: hidden;
list-style: none;
display: flex;
justify-content: space-between;
align-items: center;
}
.sec ul li{
width: 150px;
height: 150px;
position: relative;
}
.sec ul li .top{
width: 150px;
height: 150px;
border-radius: 10px;
background: -webkit-linear-gradient(top,pink,skyblue);
background: -moz-linear-gradient(top,pink,skyblue);
}
.sec ul li .down{
width: 150px;
height: 150px;
border-radius: 10px;
background-color: rgba(0,0,0,0.7);
position: absolute;
left: 0;
top: 150px;
transition: all 0.5s ease 0s;
}
.sec ul li:hover .down{
top: 0;
}
</style>
html
<div class="sec">
<ul>
<li>
<div class="top"></div>
<div class="down"></div>
</li>
<li>
<div class="top"></div>
<div class="down"></div>
</li>
<li>
<div class="top"></div>
<div class="down"></div>
</li>
</ul>
</div>
animation
火狐图标旋转
CSS
<style>
*{
margin: 0;
padding: 0;
}
p{
width: 512px;
height: 512px;
position: relative;
animation: fireFox 0.3s ease 0s infinite;
}
@keyframes fireFox{
0%{
transform: rotate(0deg)
}
50%{
transform: rotate(360deg)
}
100%{
transform: rotate(360deg)
}
}
</style>
<p>
<img src="./img/fireFox.png" alt="图片">
</p>
transform
perspective:1000px; transform-style: preserve-3d;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
body{
background-color: #000;
}
div{
width: 1000px;
height: 600px;
border: 1px solid #000;
position: absolute;
top: 50%;
left: 50%;
margin-left: -500px;
margin-top: -300px;
perspective: 1000px;
transform-style: preserve-3d;
background-color: #ffccff;
}
img{
display: block;
position: absolute;
width: 500px;
height: 281px;
left: 50%;
top: 50%;
margin-left: -250px;
margin-top: -140.5px;
transform: translateY(0deg)
}
</style>
</head>
<body>
<div>
<img src="./img/timg.jpg" alt="">
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script>
var idx = 0
setInterval(()=>{
idx+=8;
$("img").css("transform","rotateY(" + idx + "deg)");
},50)
</script>
</body>
</html>