我希望我和我世界里的人都平安幸福健康快乐!
主要知识点:
1、透视效果添加给父元素
2、3D 立体效果开启 添加给父元素
<!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>王子老师CSS进阶</title>
</head>
<style>
h1 {
color: rebeccapurple;
margin: 70px 470px;
}
body {
/* section盒子转动就给父盒子设置透视效果 */
perspective: 1000px;
}
section {
position: relative;
width: 300px;
height: 200px;
margin: 100px auto;
/* 开启3d立体效果 */
transform-style: preserve-3d;
/* 添加动画效果 */
animation: zhuandong 20s linear infinite;
background: url(./qin1.png) no-repeat;
background-size: 100% 100%;
}
section:hover {
animation-play-state: paused;
}
section div {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: url(./qin.jpg) no-repeat;
background-size: 100% 100%;
}
section .c4 {
background: url(./2.jpg) no-repeat;
background-size: 100% 100%;
}
section .c5 {
background: url(./4.jpg) no-repeat;
background-size: 100% 100%;
}
section .c6 {
background: url(./3.jpg) no-repeat;
background-size: 100% 100%;
}
section div:nth-child(1) {
transform: translateZ(300px);
}
section div:nth-child(2) {
transform: rotateY(60deg) translateZ(300px);
}
section div:nth-child(3) {
transform: rotateY(120deg) translateZ(300px);
}
section div:nth-child(4) {
transform: rotateY(180deg) translateZ(300px);
}
section div:nth-child(5) {
transform: rotateY(240deg) translateZ(300px);
}
section div:nth-child(6) {
transform: rotateY(300deg) translateZ(300px);
}
@keyframes zhuandong {
0% {
transform: rotateY(0deg);
}
100% {
transform: rotateY(360deg);
}
}
</style>
<body>
<h1>欢迎来到王子老师的CSS世界</h1>
<section>
<div></div>
<div></div>
<div></div>
<div class="c4"></div>
<div class="c5"></div>
<div class="c6"></div>
</section>
</body>
</html>