53 lines
1.7 KiB
HTML
53 lines
1.7 KiB
HTML
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<style>
|
|
body {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
min-height: 100vh; /* 使用视口高度来确保内容垂直居中 */
|
|
margin: 0; /* 去除默认的边距 */
|
|
}
|
|
.image-row {
|
|
display: flex;
|
|
flex-wrap: wrap; /* 图片容器换行 */
|
|
gap: 20px; /* 图片容器之间的间隔 */
|
|
}
|
|
.image-container {
|
|
text-align: center;
|
|
border: 2px solid #ccc;
|
|
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
|
|
transition: transform 0.3s;
|
|
flex: 1; /* 填充剩余空间,使图片容器平均分配宽度 */
|
|
max-width: 300px; /* 最大宽度 */
|
|
}
|
|
.image-container:hover {
|
|
transform: translateY(-10px);
|
|
}
|
|
img {
|
|
width: 100%;
|
|
height: auto; /* 自适应高度,防止图片变形 */
|
|
}
|
|
.image-caption {
|
|
font-size: 16px;
|
|
padding: 10px;
|
|
}
|
|
</style>
|
|
<title>带方框和上浮效果的图片</title>
|
|
</head>
|
|
<body>
|
|
<div class="image-row">
|
|
<div class="image-container">
|
|
<img src="img/about.png" alt="Image 1">
|
|
<p class="image-caption">这是图片1的说明文字。</p>
|
|
</div>
|
|
<div class="image-container">
|
|
<img src="img/about.png" alt="Image 2">
|
|
<p class="image-caption">这是图片2的说明文字。</p>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|