css相片制作
使用CSS创建相片效果
通过CSS可以模拟相片的外观,包括边框、阴影和装饰效果。以下是一种实现方式:
.photo-frame {
width: 300px;
height: 400px;
background-color: #fff;
border: 15px solid #f5f5f5;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
padding: 10px;
position: relative;
}
.photo-image {
width: 100%;
height: 100%;
object-fit: cover;
filter: sepia(20%);
}
.photo-caption {
position: absolute;
bottom: 20px;
left: 0;
right: 0;
text-align: center;
font-family: 'Courier New', monospace;
color: #333;
}
添加3D相片效果
创建更具立体感的相片效果:
.photo-3d {
transform: perspective(1000px) rotateY(10deg);
box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.3);
transition: transform 0.5s ease;
}
.photo-3d:hover {
transform: perspective(1000px) rotateY(0deg);
}
实现相片堆叠效果
模拟多张相片堆叠的外观:
.photo-stack {
position: relative;
width: 300px;
height: 400px;
}
.photo-stack img {
position: absolute;
width: 90%;
height: 90%;
border: 10px solid white;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.photo-stack img:nth-child(1) {
transform: rotate(5deg);
z-index: 1;
}
.photo-stack img:nth-child(2) {
transform: rotate(-5deg);
z-index: 2;
}
创建宝丽来风格相片
模仿宝丽来即时相机的效果:
.polaroid {
background: white;
padding: 15px 15px 40px 15px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
transform: rotate(-2deg);
transition: transform 0.3s ease;
}
.polaroid:hover {
transform: rotate(0deg);
}
.polaroid img {
width: 100%;
height: auto;
border-bottom: 1px solid #eee;
}
.polaroid-caption {
text-align: center;
font-family: 'Comic Sans MS', cursive;
color: #666;
margin-top: 10px;
}
实现相片角钉效果
添加相片被钉在墙上的视觉效果:
.photo-pinned {
position: relative;
border: 1px solid #ddd;
padding: 15px;
background: white;
}
.photo-pinned::before,
.photo-pinned::after {
content: "";
position: absolute;
width: 10px;
height: 10px;
background: #ccc;
border-radius: 50%;
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
}
.photo-pinned::before {
top: 5px;
left: 5px;
}
.photo-pinned::after {
top: 5px;
right: 5px;
}
这些CSS技巧可以组合使用或单独实现,根据需求调整参数可获得不同风格的相片效果。







