-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path伪元素实现梯形按钮.html
52 lines (46 loc) · 1.13 KB
/
伪元素实现梯形按钮.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
<!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>
.btn {
position: relative;
width: 160px;
height: 64px;
line-height: 64px;
text-align: center;
}
.btn::after {
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
transform: perspective(40px) scaleY(1.3) rotateX(10deg);
transform-origin: bottom;
background: #ff9800;
z-index: -1;
}
.btn-no-pseudo-elements {
margin-top: 50px;
width: 160px;
height: 64px;
line-height: 64px;
text-align: center;
transform: perspective(40px) scaleY(1.3) rotateX(10deg);
transform-origin: bottom;
background: #ff9800;
z-index: -1;
}
</style>
</head>
<body>
<div class="btn">BTN</div>
<div class="btn-no-pseudo-elements">BTN</div>
<p>如果不使用伪类,是由于元素经过了 transform: perspective(40px)
scaleY(1.3) rotateX(10deg),因此也导致内部的文字也变形了</p>
</body>
</html>