html炫酷相册代码
时间: 2024-06-01 19:06:14 浏览: 175
HTML 炫酷相册可以通过 CSS 和 JavaScript 实现,以下是一个简单的 HTML 炫酷相册代码示例:
```html
<!DOCTYPE html>
<html>
<head>
<title>炫酷相册</title>
<style>
body {
margin: 0;
padding: 0;
background-color: #333;
}
#gallery {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
height: 100vh;
overflow: hidden;
}
.image-container {
position: relative;
width: 200px;
height: 200px;
margin: 10px;
overflow: hidden;
cursor: pointer;
transform-style: preserve-3d;
transform: perspective(1000px);
animation: spin 10s linear infinite;
}
.image-container:hover {
animation-play-state: paused;
}
.image {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
transform-origin: center center -200px;
transform-style: preserve-3d;
backface-visibility: hidden;
transition: transform 1s ease-in-out;
}
.image:hover {
transform: translateZ(200px);
}
@keyframes spin {
from {
transform: rotateY(0);
}
to {
transform: rotateY(360deg);
}
}
</style>
</head>
<body>
<div id="gallery">
<div class="image-container">
<img class="image" src="https://picsum.photos/id/1015/600/600" alt="image">
</div>
<div class="image-container">
<img class="image" src="https://picsum.photos/id/1025/600/600" alt="image">
</div>
<div class="image-container">
<img class="image" src="https://picsum.photos/id/1035/600/600" alt="image">
</div>
</div>
</body>
</html>
```
该代码使用了 flex 布局和 3D 变换实现了炫酷相册效果。当鼠标悬停在相片上时,相片会向前翻转并向外移动一定距离。你可以通过修改样式和添加更多的图片来实现不同的效果。
阅读全文