成果展示
CSS实战第二弹
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>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/37532_lg_7bfbf0828a.jpg" alt="">
</div>
<div class="user-card-body-right">
<div class="user-card-body-right-info">
<div class="user-card-body-right-info-username">
五星大酒店
<span style="font-size: 12px; color: aliceblue; background-color: orange;">LV5</span>
</div>
<div class="user-card-body-right-info-reputation">
<span class="user-card-body-right-info-reputation-item">
<span>229</span>
<span>关注</span>
</span>
<span class="user-card-body-right-info-reputation-item">
<span>6</span>
<span>粉丝</span>
</span>
<span class="user-card-body-right-info-reputation-item">
<span>3</span>
<span>获赞</span>
</span>
</div>
</div>
<div class="user-card-body-right-button">
<button>+关注</button>
<button>发消息</button>
</div>
</div>
</div>
</div>
</body>
</html>
css代码
.user-card {
width: 366px;
height: 215px;
box-shadow: 2px 2px 5px lightgray;
border-radius: 5px;
overflow: hidden;
}
.user-card-head {
background-image: url('/static/images/mountain.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%;
}
.user-card-body-right {
width: calc(100% - 70px);
height: 100%;
float: left;
}
.user-card-body-right-info {
width: 100%;
height: 65%;
}
.user-card-body-right-info-username {
padding-left: 10px;
font-size: 16px;
color: #18191C;
font-weight: bold;
margin-bottom: 10px;
}
.user-card-body-right-info-reputation {
width: 276px;
height: 18px;
margin-left: 10px;
}
.user-card-body-right-info-reputation-item>span:nth-child(1) {
font-size: 12px;
color: #18191C;
}
.user-card-body-right-info-reputation-item>span:nth-child(2) {
font-size: 12px;
color: #9499A0;
margin-left: 3px;
}
.user-card-body-right-button>button {
width: 102px;
height: 30px;
border: none;
border-radius: 5px;
margin-right: 5px;
cursor: pointer;
}
.user-card-body-right-button>button:nth-child(1) {
background-color: #00a1d6;
color: white;
}
.user-card-body-right-button>button:nth-child(1):hover {
background-color: #00b5e5;
transition: 400ms;
}
.user-card-body-right-button>button:nth-child(2) {
background-color: white;
border: #6d757a solid 1px;
}
.user-card-body-right-button>button:nth-child(2):hover {
color: #00b5e5;
border-color: #00b5e5;
transition: 400ms;
}