<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>图片悬停模糊特效</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
padding: 20px;
text-align: center;
}
h1 {
color: #333;
margin-bottom: 30px;
}
.image-container {
display: flex;
justify-content: center;
flex-wrap: wrap;
gap: 20px;
margin-top: 30px;
}
.image-wrapper {
position: relative;
width: 200px;
height: 200px;
overflow: hidden;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
transition: filter 0.3s ease;
}
.image-wrapper img {
width: 100%;
height: 100%;
object-fit: cover;
transition: transform 0.3s ease;
}
.image-wrapper:hover img {
transform: scale(1.05);
}
/* 当悬停一个图片时,其他图片模糊 */
.image-container:hover .image-wrapper:not(:hover) {
filter: blur(3px);
}
.info {
margin: 40px auto;
padding: 20px;
background-color: white;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
max-width: 600px;
}
.info a {
color: #0066cc;
text-decoration: none;
}
.info a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<h1>图片悬停模糊特效</h1>
<div class="info">
<p>这是一个HTML5悬停模糊特效演示。当你将鼠标悬停在任意一张图片上时,其他图片会变得模糊。</p>
</div>
<div class="image-container">
<div class="image-wrapper">
<img src="https://picsum.photos/id/10/800/800" alt="风景1">
</div>
<div class="image-wrapper">
<img src="https://picsum.photos/id/11/800/800" alt="风景2">
</div>
<div class="image-wrapper">
<img src="https://picsum.photos/id/12/800/800" alt="风景3">
</div>
<div class="image-wrapper">
<img src="https://picsum.photos/id/13/800/800" alt="风景4">
</div>
<div class="image-wrapper">
<img src="https://picsum.photos/id/14/800/800" alt="风景5">
</div>
<div class="image-wrapper">
<img src="https://picsum.photos/id/15/800/800" alt="风景6">
</div>
</div>
<script>
// 这里可以添加JavaScript代码(如果需要)
document.addEventListener('DOMContentLoaded', function() {
console.log('页面加载完成');
});
</script>
</body>
</html>