要并排制作个人资料卡,可以使用HTML和CSS来实现。以下是一个简单的示例,展示了如何创建两个并排显示的个人资料卡。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>个人资料卡</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="profile-container">
<div class="profile-card">
<img src="profile1.jpg" alt="Profile 1" class="profile-image">
<h2>张三</h2>
<p>软件工程师</p>
<p>联系方式: zhangsan@example.com</p>
</div>
<div class="profile-card">
<img src="profile2.jpg" alt="Profile 2" class="profile-image">
<h2>李四</h2>
<p>前端开发者</p>
<p>联系方式: lisi@example.com</p>
</div>
</div>
</body>
</html>
/* styles.css */
body {
font-family: Arial, sans-serif;
}
.profile-container {
display: flex;
justify-content: space-around;
padding: 20px;
}
.profile-card {
border: 1px solid #ccc;
border-radius: 8px;
padding: 20px;
width: 300px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
text-align: center;
}
.profile-image {
width: 100px;
height: 100px;
border-radius: 50%;
object-fit: cover;
}
div
容器包裹两个个人资料卡。.profile-container
使用display: flex;
来并排显示子元素。.profile-card
定义了每个资料卡的样式,包括边框、内边距、阴影等。.profile-image
设置了图片的样式,使其呈现圆形。这种并排显示的个人资料卡适用于多种场景,例如:
.profile-container
的宽度足够容纳两个.profile-card
。justify-content: space-around;
或justify-content: space-between;
来均匀分布卡片。alt
属性提供替代文本,增强可访问性。通过以上步骤,你可以轻松创建并排显示的个人资料卡,并根据需要进行调整和优化。
领取专属 10元无门槛券
手把手带您无忧上云