-
Notifications
You must be signed in to change notification settings - Fork 0
/
task2.html
125 lines (124 loc) · 2.53 KB
/
task2.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>有趣的鼠标悬浮模糊效果</title>
<style>
* {
padding: 0;
margin: 0;
}
body {
font-family: "Comic Sans MS","幼圆","黑体",sans-serif;
}
.wrap {
position: relative;
width: 500px;
height: 500px;
margin: 10px auto;
}
img {
position: absolute;
width: 500px;
height: 500px;
}
.wrap:hover img {
filter: blur(5px);
}
.content {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
width: 80%;
height: 30%;
text-align: center;
}
.p1, .p2 {
display: none;
}
.p1 {
font-size: 60px;
}
.p2 {
font-size: 40px;
}
.content::before {
content: "";
display: block;
position: absolute;
left: 50%;
width: 0;
height: 100%;
box-sizing: border-box;
border: 2px solid #fff;
border-left: none;
border-right: none;
transition: all 2s;
}
.wrap:hover .content::before {
left: 0;
width: 100%;
}
.content::after {
content: "";
display: block;
position: absolute;
top: 50%;
height: 0;
width: 100%;
border: 2px solid #fff;
border-top: none;
border-bottom: none;
transition: all 2s;
box-sizing: border-box;
}
.wrap:hover .content::after {
top: 0;
height: 100%;
}
.wrap:hover p{
display: block;
background-image: -webkit-linear-gradient(left, blue, red 25%, blue 50%, red 75%, blue 100%);
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
-webkit-background-size: 200% 100%;
-webkit-animation: light 4s infinite linear;
}
@-webkit-keyframes light {
0% {
background-position: 0 0;
}
100% {
background-position: -100% 0;
}
}
.intro {
width: 500px;
text-indent: 2em;
margin: 10px auto;
font-size: 15px;
}
.intro code {
background-color: #ddd;
}
</style>
</head>
<body>
<div class="wrap">
<img src="img/2.jpg">
<div class="content">
<p class="p1">天降正义!</p>
<p class="p2">法老之鹰</p>
</div>
</div>
<div class="intro">
<h1>有趣的鼠标悬浮模糊效果</h1>
<p>背景模糊使用属性<code>filter: blur(5px);</code>不兼容IE。可在Chrome,FireFox,Edge下正常运行。</p>
<p>流光效果使用<code>-webkit-text-fill-color</code>+<code>-webkit-background-clip</code>以及渐变背景完成。在IE下无效果。</p>
<p>边框展开使用伪元素<code>::before</code>与<code>::after</code>配合<code>transition</code>完成。</p>
</div>
</body>
</html>