Skip to content

Commit f7c4f3c

Browse files
committed
css实现价格标签
1 parent 37c7e03 commit f7c4f3c

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>价格标签</title>
6+
<style>
7+
:root {
8+
--price-tag-background: red;
9+
--price-tag-height: 32px;
10+
}
11+
12+
.price-tag {
13+
margin-left: 30px;
14+
position: relative;
15+
max-width: 80px;
16+
padding: 0 5px;
17+
height: var(--price-tag-height);
18+
background: var(--price-tag-background);
19+
color: #fff;
20+
display: flex;
21+
align-items: center;
22+
justify-content: center;
23+
}
24+
25+
.price-tag::before {
26+
content: "";
27+
border: calc(var(--price-tag-height) / 2) solid transparent;
28+
border-right-color: red;
29+
position: absolute;
30+
left: 0;
31+
top: 0;
32+
transform: translate(-100%, 0);
33+
}
34+
35+
.price-tag::after {
36+
content: "";
37+
width: 10px;
38+
height: 10px;
39+
background: #fff;
40+
border-radius: 9999rem;
41+
position: absolute;
42+
left: 0;
43+
top: 50%;
44+
transform: translate(-50%, -50%);
45+
}
46+
</style>
47+
</head>
48+
<body>
49+
<div class="price-tag">¥99.09</div>
50+
</body>
51+
</html>

0 commit comments

Comments
 (0)