2D变形
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
div {
width: 140px;
height: 140px;
background-color: green;
transition: all 1s;
}
div:active {
transform: translate(200px,100px);
}
</style>
</head>
<body>
<div>
</div>
</body>
</html>
绝对定位的盒子水平居中
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
div {
width: 400px;
height: 200px;
background: red;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
}
</style>
</head>
<body>
<div></div>
</body>
</html>
2D变形之缩放
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
div {
width: 100px;
height: 100px;
background-color: blue;
margin: 50px auto;
transition: all 1s;
}
div:hover {
transform: scale(2);
}
section {
width: 150px;
height: 150px;
margin: 0 auto;
overflow: hidden;
}
section img {
transition: all 1s;
}
section:hover img {
transform: scale(1.2);
}
</style>
</head>
<body>
<div></div>
<section>
<img src="img/img.jpg" alt="">
</section>
</body>
</html>
2D变形之旋转
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
img {
margin: 100px;
border-radius: 50%;
transition: all 1s;
}
img:hover {
transform: rotate(1080deg);
}
</style>
</head>
<body>
<img src="img/img.jpg" alt="">
</body>
</html>
变形中心点
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
img {
width: 200px;
margin: 100px;
transition: all 1s;
transform-origin: 50px 60px;
}
img:hover {
transform: rotate(360deg);
}
div {
width: 200px;
margin: 0 auto;
position: relative;
}
div img {
position: absolute;
left: 0;
top: 0;
transform-origin:top right;
}
div:hover img:nth-child(1) {
transform: rotate(60deg);
}
div:hover img:nth-child(2) {
transform: rotate(120deg);
}
div:hover img:nth-child(3) {
transform: rotate(180deg);
}
div:hover img:nth-child(4) {
transform: rotate(240deg);
}
div:hover img:nth-child(5) {
transform: rotate(300deg);
}
div:hover img:nth-child(6) {
transform: rotate(360deg);
}
</style>
</head>
<body>
<img src="img/pk.jpg" alt="">
<div>
<img src="img/pk.jpg" alt="">
<img src="img/pk.jpg" alt="">
<img src="img/pk.jpg" alt="">
<img src="img/pk.jpg" alt="">
<img src="img/pk.jpg" alt="">
<img src="img/pk.jpg" alt="">
</div>
</body>
</html>
2D变形之倾斜
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
div {
font-size: 50px;
font-weight: 700;
margin: 100px;
transition: all 1s;
}
div:hover {
transform: skew(0,-30deg);
}
</style>
</head>
<body>
<div>钓鱼岛是中国的</div>
</body>
</html>