<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
html{
perspective: 800px;
}
img{
width: 200px;
height: 200px;
}
.cube{
width: 200px;
height: 200px;
/* background-color: #bfa; */
margin: 100px auto;
/* 设置3D变形效果 */
transform-style: preserve-3d;
animation: rotate 20s infinite linear;
}
.cube>div{
width: 200px;
height: 200px;
/* 为元素设置透明效果 */
opacity: 0.7;
position: absolute;
}
img{
vertical-align: top;
}
.box1{
transform: rotateY(90deg) translateZ(100px);
}
.box2{
transform: rotateY(-90deg) translateZ(100px);
}
.box3{
transform: rotateX(90deg) translateZ(100px);
}
.box4{
transform: rotateX(-90deg) translateZ(100px);
}
.box5{
transform: rotateX(180deg) translateZ(100px);
}
.box6{
transform: translateZ(100px);
}
@keyframes rotate {
form{
transform: rotateX(0) rotateZ(0);
}
to{
transform: rotateX(1turn) rotateZ(1turn);
}
}
</style>
</head>
<body>
<div class="cube">
<div class="box1">
<img src="./img/1.jpg">
</div>
<div class="box2">
<img src="./img/2.jpg">
</div>
<div class="box3">
<img src="./img/3.jpg">
</div>
<div class="box4">
<img src="./img/4.jpg">
</div>
<div class="box5">
<img src="./img/5.jpg">
</div>
<div class="box6">
<img src="./img/6.jpg">
</div>
</div>
</body>
</html>
Html+Css小tips:立体旋转小方块(练习)
最新推荐文章于 2024-07-13 17:22:05 发布