父级perspective与子元素transform:perspective的区别
在父级加perspective
效果是每个子div都不同,相当于站在一个视角看多个div
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body {
perspective:1000px;
}
.box {
float: left;
width: 200px;
height: 200px;
margin: 50px 20px 0 0;
transform:rotateY(45deg);
background-color: red;
}
</style>
</head>
<body>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</body>
</html>
在元素本身加perspective
每个子div效果都一样,每个视角都独立
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body {
}
.box {
float: left;
width: 200px;
height: 200px;
margin: 50px 20px 0 0;
transform:perspective(1000px) rotateY(45deg);
background-color: red;
}
</style>
</head>
<body>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</body>
</html>
原文地址:https://blog.csdn.net/aexwx/article/details/145279605
免责声明:本站文章内容转载自网络资源,如侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!