css制作信封
使用CSS制作信封效果
通过CSS的边框、阴影和伪元素可以模拟一个信封的平面设计效果。以下是一个简洁的实现方案:
<div class="envelope"></div>
.envelope {
width: 300px;
height: 200px;
background: #f8f1e6;
position: relative;
border: 1px solid #d4c9b8;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
margin: 50px auto;
}
.envelope::before {
content: '';
position: absolute;
top: 0;
width: 0;
height: 0;
border-left: 150px solid transparent;
border-right: 150px solid transparent;
border-top: 100px solid #e8d5b5;
z-index: 2;
}
.envelope::after {
content: '';
position: absolute;
bottom: 0;
width: 250px;
height: 150px;
background: #f0e6d2;
left: 25px;
border: 1px dashed #c0b4a0;
}
添加动态交互效果
为信封添加悬停动画,模拟打开效果:
.envelope:hover::before {
transform: rotateX(180deg);
transform-origin: top;
transition: transform 0.5s ease;
}
.envelope:hover {
box-shadow: 0 10px 20px rgba(0,0,0,0.2);
transition: all 0.3s ease;
}
增加细节装饰
添加邮票和收件人信息等装饰元素:
<div class="envelope">
<div class="stamp">邮票</div>
<div class="address">收件人信息</div>
</div>
.stamp {
position: absolute;
top: 15px;
right: 15px;
width: 50px;
height: 60px;
background: #ff0000;
color: white;
text-align: center;
line-height: 60px;
border: 1px dashed white;
}
.address {
position: absolute;
bottom: 40px;
left: 30px;
font-family: cursive;
color: #333;
}
响应式调整
通过媒体查询适应不同屏幕尺寸:

@media (max-width: 600px) {
.envelope {
width: 200px;
height: 150px;
}
.envelope::before {
border-left: 100px solid transparent;
border-right: 100px solid transparent;
border-top: 75px solid #e8d5b5;
}
}
这些CSS技巧组合可以创建出逼真的信封效果,通过调整颜色、尺寸和细节元素,能够实现各种风格的信封设计。






