HTML部分:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link rel="stylesheet" href="./index.css" />
<title>Flex 布局</title>
</head>
<body>
<div class="container">
<div class="icon">
<img src="./images/icon.png" alt="" />
</div>
<div class="avatar">
<img src="./images/avatar.png" alt="" />
</div>
<div class="userinfo">
<div class="name">小脏包</div>
<div class="text">本周送花520朵,爱慕值1314</div>
</div>
</div>
</body>
</html>
CSS部分:
.container {
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
border-radius: 4px;
width: 300px;
height: 70px;
box-sizing: border-box;
padding: 0 20px;
display: flex;
align-items: center;
}
.icon {
width: 25px;
height: 37px;
margin-right: 6px;
}
.icon img {
width: 100%;
}
.avatar {
width: 48px;
height: 48px;
margin-right: 13px;
}
.avatar img {
width: 100%;
border-radius: 50%;
}
.name {
font-weight: 500;
color: #646464;
}
.text {
font-size: 12px;
color: #808080;
}