1. transform 2D、3D转换
- transform 属性语法 :
transform: none|transform-functions;
详细查看
2. 过渡
- 过渡属性手册
- timing-function 的属性使用
transition: property duration timing-function delay;
property
指定CSS属性的name,transition效果
duration
效果持续时间
timing-function
指定transition效果的转速曲线方式
delay
延时时间
- 动画移动、旋转、缩放、倾斜所有示例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.box{
width: 100px;
height: 100px;
background-color: red;
transform: translateX(100px);
transform: translateY(100px);
transform: translateZ(100px);
transform: skewX(1deg);
transform: skewY(2deg);
transform: translate(100px,200px);
transform: rotate(45deg);
transform: scale(1,2);
transform: skew(45deg,0deg);
transform: matrix(2,0.45,0.1,3,100,200);
transform: translate3d(100px,200px,100px);
transform: rotate3d(1,1,0,45deg);
transform: scale3d(1,2,3);
transform-origin: 0px 0px ;
transition: transorm 3s linear 2s,background-color 3s linear;
}
.box:hover{
transform: rotate(1112deg);
background-color: orange;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>menu</title>
<style type="text/css">
nav {
width: 600px;
height: 40px;
margin: 100px auto 0;
padding: 0 20px;
background-color: #ff2121;
box-shadow: 0px 4px 0px #f20c00;
border-radius: 20px;
}
nav ul {
list-style-type: none;
margin: 0;
padding: 0;
height: 40px;
}
nav ul li {
float: left;
width: 100px;
height: 40px;
text-align: center;
line-height: 40px;
position: relative;
overflow: hidden;
}
nav ul li::after {
content: "";
display: inline-block;
width: 2px;
height: 30px;
background: linear-gradient(#ff2121, #bf242a, #ff2121);
position: absolute;
right: 0;
top: 5px;
}
nav ul li:last-child::after {
display: none;
}
nav ul li::before {
content: "";
display: inline-block;
width: 30px;
height: 120px;
background: linear-gradient(to left, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.05));
position: absolute;
top: -30px;
left: -70px;
transform: rotate(45deg);
transition: all 0.4s ease;
}
nav ul li:hover::before {
left: 80px;
}
nav ul li a {
text-decoration: none;
font-size: 14px;
color: #fff;
}
</style>
</head>
<body>
<nav>
<ul>
<li><a href="">index1</a></li>
<li><a href="">index2</a></li>
<li><a href="">index3</a></li>
<li><a href="">index4</a></li>
<li><a href="">index5</a></li>
<li><a href="">index6</a></li>
</ul>
</nav>
</body>
</html>