照片墙html,增加样式代码
时间: 2023-10-16 07:10:40 浏览: 42
好的,以下是一个简单的照片墙 HTML 代码,并添加了一些样式代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>照片墙</title>
<style>
body {
margin: 0;
padding: 0;
background-color: #ccc;
}
h1 {
text-align: center;
margin: 20px 0;
color: #333;
}
.container {
max-width: 1200px;
margin: 0 auto;
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.image {
width: 300px;
height: 300px;
margin: 10px;
overflow: hidden;
border: 5px solid white;
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
position: relative;
}
.image:hover .overlay {
opacity: 1;
}
.overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
color: white;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
opacity: 0;
transition: opacity 0.5s;
}
.overlay h2 {
font-size: 24px;
margin-top: 0;
}
.overlay p {
font-size: 18px;
margin-bottom: 0;
}
</style>
</head>
<body>
<h1>我的照片墙</h1>
<div class="container">
<div class="image">
<img src="image1.jpg" alt="图片1">
<div class="overlay">
<h2>图片1</h2>
<p>这是一张美丽的风景照片。</p>
</div>
</div>
<div class="image">
<img src="image2.jpg" alt="图片2">
<div class="overlay">
<h2>图片2</h2>
<p>这是一张可爱的宠物照片。</p>
</div>
</div>
<div class="image">
<img src="image3.jpg" alt="图片3">
<div class="overlay">
<h2>图片3</h2>
<p>这是一张神奇的自然照片。</p>
</div>
</div>
<!-- 添加更多的图片 -->
</div>
</body>
</html>
```
这些样式代码包括了背景颜色、标题样式、容器样式、图片样式和悬停效果。你可以根据需要自定义这些样式,或者添加新的样式来美化你的照片墙。