<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
html{
/* Z轴平移属于立体效果(近大远小),默认情况下网页是不支持透视效果的,如果我们需要看到这个效果
我们必须设置网页的视距(建议:600px-1200px)*/
perspective :800px;
}
.box1{
width: 200px;
height: 200px;
background-color:#bfa;
margin: 200px auto;
/*
z轴平移,调整元素在z轴的位置,正常情况就是调整元素和人眼之间的距离
距离越大,离我们越近
*/
transition: all 0.5s;
}
body{
border: tomato 1px solid;
}
body:hover .box1{
transform: translateZ(150px);
}
</style>
</head>
<body>
<div class="box1"></div>
</body>
</html>
27变形-Z轴平移——HTML
最新推荐文章于 2022-04-14 08:52:41 发布