-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilter与backdrop-filter2.html
61 lines (52 loc) · 1.22 KB
/
filter与backdrop-filter2.html
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
<!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>
div {
position: relative;
width: 200px;
height: 200px;
background: url(./pics/pic.png);
background-size: contain;
}
.backdrop::before {
content: "";
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
backdrop-filter: grayscale(100%);
transition: 1s transform;
}
.backdrop:hover::before {
transform: translate(100%, 0);
}
/* 作用于元素本身 */
.filter {
filter: grayscale(100%);
}
/* 下面这样是不生效的因为!filter作用于元素本身!!! */
/* .filter::before {
content: "";
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
filter: grayscale(100%);
}
.filter:hover::before {
transform: translate(100%, 0);
} */
</style>
</head>
<body>
<!-- backdrop-filter的作用范围是元素背后区域的所有元素,而这个区域是可以移动的!!! -->
<div class="backdrop"></div>
<div class="filter"></div>
</body>
</html>