CSS-2D转换模块
原创
©著作权归作者所有:来自51CTO博客作者一个爱听音乐的程序员的原创作品,请联系作者获取转载授权,否则将追究法律责任
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>2D转换模块</title>
<style>
* {
margin: 0;
padding: 0;
}
ul {
width: 800px;
height: 500px;
border: 1px solid #000;
margin: 0 auto;
}
ul li {
list-style: none;
width: 100px;
height: 50px;
background-color: red;
margin: 0 auto;
margin-top: 50px;
text-align: center;
line-height: 50px;
}
ul li:nth-child(2) {
transform: rotate(45deg);
}
ul li:nth-child(3) {
transform: translate(100px, 0px);
}
ul li:nth-child(4) {
transform: scale(1.5);
}
ul li:nth-child(5) {
transform: rotate(45deg) translate(100px, 0px) scale(1.5, 1.5);
}
</style>
</head>
<body>
<ul>
<li>正常的</li>
<li>旋转的</li>
<li>平移的</li>
<li>缩放的</li>
<li>综合的</li>
</ul>
</body>
</html>
形变中心点
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>2D转换模块-形变中心点</title>
<style>
* {
margin: 0;
padding: 0;
}
ul {
width: 200px;
height: 200px;
border: 1px solid #000;
margin: 100px auto;
position: relative;
}
ul li {
list-style: none;
width: 200px;
height: 200px;
position: absolute;
left: 0;
top: 0;
transform-origin: left top;
}
ul li:nth-child(1) {
background-color: red;
transform: rotate(30deg);
}
ul li:nth-child(2) {
background-color: green;
transform: rotate(50deg);
}
ul li:nth-child(3) {
background-color: blue;
transform: rotate(70deg);
}
</style>
</head>
<body>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</body>
</html>
旋转轴向
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>2D转换模块-旋转轴向</title>
<style>
* {
margin: 0;
padding: 0;
}
ul {
width: 800px;
height: 500px;
margin: 0 auto;
}
ul li {
list-style: none;
width: 200px;
height: 200px;
margin: 0 auto;
margin-top: 50px;
border: 1px solid #000;
perspective: 500px;
}
ul li img {
width: 200px;
height: 200px;
}
ul li:nth-child(1) {
transform: rotateZ(45deg);
}
ul li:nth-child(2) img {
transform: rotateX(45deg);
}
ul li:nth-child(3) img {
transform: rotateY(45deg);
}
</style>
</head>
<body>
<ul>
<li><img src="images/rotateZ.jpg" alt=""></li>
<li><img src="images/rotateX.jpg" alt=""></li>
<li><img src="images/rotateY.jpg" alt=""></li>
</ul>
</body>
</html>
练习
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>2D转换模块-small Demo</title>
<style>
* {
margin: 0;
padding: 0;
}
div {
width: 310px;
height: 438px;
border: 1px solid #000;
background-color: skyblue;
margin: 100px auto;
perspective: 500px;
}
div img {
transform-origin: center bottom;
transition: transform 1s;
}
div:hover img {
transform: rotateX(80deg);
}
</style>
</head>
<body>
<div>
<img src="images/pk.png" alt="">
</div>
</body>
</html>
相片墙
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>2D转换模块-相片墙</title>
<style>
* {
margin: 0;
padding: 0;
}
ul {
height: 400px;
border: 1px solid #000;
background-color: skyblue;
margin-top: 100px;
text-align: center;
}
ul li {
list-style: none;
width: 150px;
height: 200px;
background-color: red;
display: inline-block;
margin-top: 100px;
transition: all 1s;
position: relative;
box-shadow: 0 0 10px;
}
ul li:nth-child(1) {
transform: rotate(30deg);
}
ul li:nth-child(2) {
transform: rotate(-40deg);
}
ul li:nth-child(3) {
transform: rotate(10deg);
}
ul li:nth-child(4) {
transform: rotate(45deg);
}
ul li img {
width: 150px;
height: 200px;
border: 5px solid #fff;
box-sizing: border-box;
}
ul li:hover {
transform: scale(1.5);
z-index: 998;
}
</style>
</head>
<body>
<ul>
<li><img src="images/1.jpg" alt=""></li>
<li><img src="images/2.jpg" alt=""></li>
<li><img src="images/3.jpg" alt=""></li>
<li><img src="images/4.jpg" alt=""></li>
</ul>
</body>
</html>