CSS生成2行两列,每列左边是图标,右边两行显示文字的列表样式
CSS
2025-02-13 15:45
75
0
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta nameviewport="" content="width=device-width, initial-scale=1.0">
<title>列表样式</title>
<style>
.list-container {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 20px;
width: 80%;
max-width: 600px;
}
.list-item {
display: flex;
align-items: center;
background-color: #fff;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.list-icon {
width: 40px;
height: 40px;
margin-right: 10px;
border-radius: 50%;
object-fit: cover;
}
.list-text {
display: flex;
flex-direction: column;
justify-content: center;
}
.list-text p {
margin: 0;
line-height: 1.5;
}
</style>
</head>
<body>
<div>
<div>
<img src="icon1.png" alt="Icon 1">
<div>
<p>第一行文字</p>
<p>第二行文字</p>
</div>
</div>
<div>
<img src="icon2.png" alt="Icon 2">
<div>
<p>第一行文字</p>
<p>第二行文字</p>
</div>
</div>
<div>
<img src="icon3.png" alt="Icon 3">
<div>
<p>第一行文字</p>
<p>第二行文字</p>
</div>
</div>
<div>
<img src="icon4.png" alt="Icon 4">
<div>
<p>第一行文字</p>
<p>第二行文字</p>
</div>
</div>
</div>
</body>
</html>