效果图:
<!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/style.css" type="text/css">
</head>
<body>
<div class="user-card">
<div class="user-card-background"></div>
<div class="user-card-body">
<div class="user-card-body-left">
<img src="https://cdn.acwing.com/media/user/profile/photo/79054_lg_d0f775e7d7.jpg" alt="头像">
</div>
<div class="user-card-body-right">
<div class="user-card-body-right-text">
<div class="user-card-body-right-text-username">
带刀的猪
<span>Lv5</span>
</div>
<div class="user-card-body-right-text-reputation">
<span class="user-card-body-right-text-reputation-item">
<span>148</span>
<span>关注</span>
</span>
<span class="user-card-body-right-text-reputation-item">
<span>4</span>
<span>粉丝</span>
</span>
<span class="user-card-body-right-text-reputation-item">
<span>9</span>
<span>获赞</span>
</span>
</div>
</div>
<div class="user-card-body-right-button">
<button>+关注</button>
<button>发消息</button>
</div>
</div>
</div>
</div>
</body>
</html>
.user-card {
height: 215px;
width: 366px;
box-shadow: 2px 2px 5px lightgray;
border-radius: 5px;
}
.user-card-background {
background-image: url('/static/images/bilibili.jpg');
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-left>img {
width: 48px;
height: 48px;
border-radius: 50%;
border: 1px solid lightsteelblue;
}
.user-card-body-right {
width: calc(100% - 70px);
height: 100%;
float: left;
}
.user-card-body-right-text {
width: 100%;
height: 70%;
box-sizing: border-box;
}
.user-card-body-right-text-username {
font-size: 16px;
color: #222222;
font-weight: bold;
margin-bottom: 10px;
}
.user-card-body-right-text-reputation {}
.user-card-body-right-text-username>span {
font-style: italic;
font-size: 12px;
color: #8bd29b;
padding: 0 0 0 6px;
}
.user-card-body-right-text-reputation-item>span:nth-child(1) {
font-size: 12px;
color: #222222;
}
.user-card-body-right-text-reputation-item>span:nth-child(2) {
font-size: 12px;
color: #9499a0;
margin-right: 20px;
}
.user-card-body-right-button {
width: 100%;
}
.user-card-body-right-button button {
width: 102px;
height: 30px;
margin-right: 6px;
border-radius: 5px;
/* 鼠标放在该元素上变成小手 */
cursor: pointer;
}
.user-card-body-right-button>button:nth-child(1) {
background-color: #00A1D6;
color: white;
font-size: 16px;
border-style: none;
}
.user-card-body-right-button>button:nth-child(2) {
background-color: white;
color: #6d757a;
font-size: 16px;
border: 1px #ccd0d7 solid;
}
.user-card-body-right-button>button:nth-child(1):hover {
opacity: 0.8;
transition: 400ms;
}
.user-card-body-right-button>button:nth-child(2):hover {
border-color: #00b5e5;
color: #00b5e5;
transition: 400ms;
}