Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
77 lines (77 loc) · 2.27 KB
/
Copy pathindex.html
File metadata and controls
77 lines (77 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="../commonScript/note/note.css" />
<title>图片景深效果</title>
<style>
body {
background-color: #F6F6F6;
}
.container {
perspective: 1px;
height: 800px;
overflow-x: hidden;
}
.box {
position: relative;
transform-style: preserve-3d;
height: 1200px;
}
.girl {
position: absolute;
width: 800px;
left: 50%;
top: 500px;
transform: translate3d(-50%, 0, -1px) scale(2);
}
.flower {
position: absolute;
width: 200px;
left: 112%;
top: 30%;
transform: translateZ(-2px) scale(3);
}
.flower img {
width: 200px;
}
.flower-copy {
position: absolute;
width: 200px;
left: 18%;
top: 50%;
transform: rotateY(180deg);
}
.flower-copy img {
width: 200px;
}
</style>
</head>
<body>
<div class="container">
<div class="box">
<img class="girl" src="./girl.jpg" alt="picture" />
<div class="flower">
<img id="pic" src="./flower.jpg" alt="" />
</div>
<div class="flower-copy">
<img src="./flower.jpg" alt="" />
</div>
</div>
</div>
<script src="../commonScript/note/note.js"></script>
<script type="text/javascript">
window.addEventListener('DOMContentLoaded', function () {
let data = [
'perspective代表眼睛到屏幕的距离,该属性只对应用3d转换的元素有效,translateZ代表元素到屏幕的位置,眼睛方向为正。',
'perspective对子元素生效,对元素本身无效,结合transform-style:preserve-3d(子元素将保留其3d位置)使用,可以达到距离近的会覆盖距离远的元素,否者后者覆盖前者。',
'dom的搭建比较随意,良好的dom结构能更方便的调试和扩展',
'景深效果是把元素拉远再放大,看的大小和原来的大小是一样的,但是滚动时移动的距离却是z=0上元素的几分之一,就导致了滚动的速度不一样',
'如果没有设置z轴,默认都是在z=0的平面上,没有perspective属性的时候默认都是从无限远的地方看,也就不会有3d效果',
'perspective的值应该大于元素到屏幕的距离,否则元素就在眼睛的上方,也就不可能看到元素了'
];
Note.init(data);
}, false);
</script>
</body>
</html>