<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>图片文字悬停特效</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Arial', sans-serif;
background-color: #f5f5f5;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
padding: 20px;
}
.gallery {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 30px;
max-width: 1200px;
}
.image-card {
position: relative;
width: 300px;
height: 200px;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.image-card:hover {
transform: translateY(-10px);
box-shadow: 0 15px 30px rgba(0,0,0,0.2);
}
.image-card img {
width: 100%;
height: 100%;
object-fit: cover;
transition: all 0.5s ease;
}
.image-card:hover img {
transform: scale(1.1);
filter: brightness(0.7);
}
.image-overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
padding: 20px;
color: white;
transform: translateY(100%);
transition: transform 0.5s ease;
opacity: 0;
}
.image-card:hover .image-overlay {
transform: translateY(0);
opacity: 1;
}
.image-title {
font-size: 22px;
margin-bottom: 10px;
transform: translateY(20px);
transition: transform 0.3s ease 0.2s;
}
.image-card:hover .image-title {
transform: translateY(0);
}
.image-desc {
font-size: 14px;
line-height: 1.5;
margin-bottom: 15px;
transform: translateY(20px);
transition: transform 0.3s ease 0.3s;
opacity: 0;
}
.image-card:hover .image-desc {
transform: translateY(0);
opacity: 1;
}
.image-btn {
display: inline-block;
padding: 8px 20px;
background-color: #3498db;
color: white;
text-decoration: none;
border-radius: 50px;
font-size: 14px;
transform: translateY(20px);
transition: all 0.3s ease 0.4s;
opacity: 0;
}
.image-card:hover .image-btn {
transform: translateY(0);
opacity: 1;
}
.image-btn:hover {
background-color: #2980b9;
}
/* 特殊效果 - 边框动画 */
.image-card::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border: 2px solid transparent;
border-radius: 8px;
z-index: 1;
transition: all 0.5s ease;
pointer-events: none;
}
.image-card:hover::before {
border-color: rgba(255,255,255,0.5);
top: 10px;
left: 10px;
right: 10px;
bottom: 10px;
}
</style>
</head>
<body>
<div class="gallery">
<div class="image-card">
<img src="https://picsum.photos/600/400?random=1" alt="风景图片">
<div class="image-overlay">
<h3 class="image-title">美丽风景</h3>
<p class="image-desc">这是一张美丽的风景照片,展现了自然的壮丽与宁静。</p>
<a href="#" class="image-btn">查看详情</a>
</div>
</div>
<div class="image-card">
<img src="https://picsum.photos/600/400?random=2" alt="城市风光">
<div class="image-overlay">
<h3 class="image-title">城市风光</h3>
<p class="image-desc">现代都市的繁华景象,高楼林立,灯火辉煌。</p>
<a href="#" class="image-btn">查看详情</a>
</div>
</div>
<div class="image-card">
<img src="https://picsum.photos/600/400?random=3" alt="海滩日落">
<div class="image-overlay">
<h3 class="image-title">海滩日落</h3>
<p class="image-desc">金色的阳光洒在海面上,形成一幅美丽的日落画卷。</p>
<a href="#" class="image-btn">查看详情</a>
</div>
</div>
</div>
</body>
</html>
287

被折叠的 条评论
为什么被折叠?



