This commit is contained in:
teasiu
2023-10-11 00:37:39 +08:00
parent 55931dc245
commit 9dc3625c72

View File

@@ -1,3 +1,4 @@
<!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
@@ -5,39 +6,44 @@
<style> <style>
body { body {
display: flex; display: flex;
justify-content: center; flex-direction: column;
justify-content: flex-start; /* 内容靠上居中 */
align-items: center; align-items: center;
min-height: 100vh; /* 使用视口高度来确保内容垂直居中 */ min-height: 100vh;
margin: 0; /* 去除默认的边距 */ margin: 0;
}
h1 {
margin: 20px 0; /* 添加标题上下边距 */
} }
.image-row { .image-row {
display: flex; display: flex;
flex-wrap: wrap; /* 图片容器换行 */ flex-wrap: wrap;
gap: 20px; /* 图片容器之间的间隔 */ gap: 20px;
} }
.image-container { .image-container {
text-align: center; text-align: center;
border: 2px solid #ccc; border: 2px solid #ccc;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2); box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
transition: transform 0.3s; transition: transform 0.3s;
flex: 1; /* 填充剩余空间,使图片容器平均分配宽度 */ flex: 1;
max-width: 300px; /* 最大宽度 */ max-width: 300px;
} }
.image-container:hover { .image-container:hover {
transform: translateY(-10px); transform: translateY(-10px);
} }
img { img {
width: 100%; width: 100%;
height: auto; /* 自适应高度,防止图片变形 */ height: auto;
} }
.image-caption { .image-caption {
font-size: 16px; font-size: 16px;
padding: 10px; padding: 10px;
} }
</style> </style>
<title>带方框和上浮效果的图片</title> <title>捐助与远程协助</title>
</head> </head>
<body> <body>
<h1>捐助作者</h1> <!-- 添加标题 -->
<div class="image-row"> <div class="image-row">
<div class="image-container"> <div class="image-container">
<img src="img/about.png" alt="Image 1"> <img src="img/about.png" alt="Image 1">