仿Bilibli个人名片

效果:

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
<!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>Document</title>
<link rel="stylesheet" href="/static/css/bilibili.css" />
</head>
<body>
<div class="user-card">
<div class="user-card-head"></div>
<div class="user-card-body">
<div class="user-card-body-left">
<img
src="https://cdn.acwing.com/media/user/profile/photo/171103_lg_6fce1eaf39.png"
alt=""
/>
</div>
<div class="user-card-body-right">
<div class="user-card-body-right-text">
<div class="user-card-body-right-text-username">
鹿乃knao
<span class="user-card-body-right-text-username-item">lv5</span>
</div>
<div class="user-card-right-text-reputation">
<span class="user-card-right-text-reputation-item">
<span>520</span>
<span>关注</span>
</span>
<span class="user-card-right-text-reputation-item">
<span>520</span>
<span>粉丝</span>
</span>
<span class="user-card-right-text-reputation-item">
<span>520</span>
<span>获赞</span>
</span>
</div>
</div>
<div class="user-card-body-right-button">
<button>+关注</button>
<button>发消息</button>
</div>
</div>
</div>
</div>
</body>
</html>


CSS实现

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
.user-card {
width: 366px;
height: 215px;
box-shadow: 2px 2px 5px lightblue;
border-radius: 5px;
}

.user-card-head {
background-image: url("/static/images/优.png");
background-size: cover;
width: 100%;
height: 85px;
}

.user-card-body {
width: 100%;
height: calc(100% - 85px);
box-sizing: border-box;
padding-top: 12px;
}

.user-card-body-left {
width: 70px;
height: 100%;

float: left;
text-align: center;
}

.user-card-body-right {
width: calc(100% - 70px);
height: 100%;
float: left;
}

.user-card-body-left > img {
width: 50px;
height: 50px;
border-radius: 50%;
}

.user-card-body-right-text {
width: 100%;
height: 78px;
}

.user-card-body-right-text-username {
font-size: 16px;
font-weight: bolder;
color: #fb7299;
}

.user-card-body-right-text-username-item {
font-size: 12px;
font-style: italic;
color: #e46829;
padding-left: 6px;
}

.user-card-right-text-reputation {
margin-top: 12px;
}

.user-card-right-text-reputation-item > span:nth-child(1) {
font-size: 12px;
color: #222222;
}

.user-card-right-text-reputation-item > span:nth-child(2) {
font-size: 12px;
color: #9499a0;
padding-right: 20px;
}

.user-card-right-body-button {
width: 100%;
height: calc(100% - 78px);
}

.user-card-body-right-button > button:nth-child(1) {
box-sizing: border-box;
padding-right: 1px;
margin-right: 6px;
width: 90px;
height: 25px;
border-radius: 5px;
border-style: none;
background-color: #00b5e5;
color: white;
cursor: pointer;
}

.user-card-body-right-button > button:nth-child(2) {
box-sizing: border-box;
padding-right: 1px;
margin-right: 6px;
width: 90px;
height: 25px;
border-radius: 5px;
background-color: white;
border: #ccd0d7 solid 1px;
color: #60757a;
cursor: pointer;
}

.user-card-body-right-button > button:nth-child(2):hover {
border-color: #00b5e5;
color: #00b5e5;
transition: 700ms;
}

.user-card-body-right-button > button:nth-child(1):hover {
background-color: lightpink;
color: white;
transition: 700ms;
}