效果预览:效果预览
源码下载:关注公众号【RMRF】,回复【css7】可获取源码
一、HTML
<!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>按钮</title>
<link rel="stylesheet" href="./css/index.css">
</head>
<body>
<button>
<span>Hellow World</span>
<div class="top"></div>
<div class="bottom"></div>
<div class="left"></div>
<div class="right"></div>
</button>
</body>
</html>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
二、CSS样式
body {
display: flex;
justify-content: center;
background-color: #202020;
}
button {
position: relative;
margin-top: 300px;
padding: 20px 60px;
cursor: pointer;
transition: 0.5s all;
background-color: #202020;
}
button span {
color: #646464;
font-size: 20px;
}
button:hover {
box-shadow: inset 0px 0px 25px #ff7700;
}
button:active {
margin-top: 305px;
transition: 0.2s all;
box-shadow: inset 0px 0px 25px #ffaf6a;
}
button div {
transition: 0.5s all;
position: absolute;
background-color: #ff7700;
box-shadow: 0 0 15px #ff7700, 0 0 30px #ff7700, 0 0 50px #ff7700;
}
button .top {
width: 15px;
height: 2px;
top: 0;
left: 0;
}
button .bottom {
width: 15px;
height: 2px;
bottom: 0;
right: 0;
}
button .left {
width: 2px;
height: 15px;
top: 0;
left: 0;
}
button .right {
width: 2px;
height: 15px;
right: 0;
bottom: 0;
}
button:hover .top,
button:hover .bottom {
width: 100%;
}
button:hover .left,
button:hover .right {
height: 100%;
}
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
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