css信件制作
使用CSS制作信件样式
通过CSS可以模拟传统信件的视觉风格,包括纸张质感、边距、字体和装饰元素。以下是一个完整的信件样式实现方案:
信件容器样式
设置信纸的基本样式,模拟纸张质感和边缘效果:
.letter {
width: 80%;
max-width: 800px;
margin: 2rem auto;
padding: 3rem;
background-color: #f9f5e9;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
border: 1px solid #e0d5c0;
position: relative;
line-height: 1.6;
font-family: 'Georgia', serif;
}
信头设计
创建传统的信头布局,包含日期和地址:
.letter-header {
text-align: right;
margin-bottom: 2rem;
border-bottom: 1px solid #d0c0a0;
padding-bottom: 1rem;
}
.address {
text-align: left;
margin-top: 1rem;
font-style: italic;
}
正文样式
设置舒适的阅读体验:

.letter-body {
margin: 2rem 0;
font-size: 1.1rem;
}
.letter-body p {
margin-bottom: 1rem;
text-align: justify;
}
签名区域
添加手写风格的签名区域:
.letter-signature {
margin-top: 3rem;
font-family: 'Brush Script MT', cursive;
font-size: 1.5rem;
color: #333;
}
.signature-line {
display: inline-block;
width: 200px;
border-top: 1px solid #333;
margin-left: 1rem;
}
装饰元素
添加复古装饰元素增强视觉效果:

.letter::before {
content: "";
position: absolute;
top: 10px;
left: 10px;
right: 10px;
bottom: 10px;
border: 1px solid rgba(0,0,0,0.05);
pointer-events: none;
}
.corner-decoration {
position: absolute;
width: 50px;
height: 50px;
border: 1px solid #d0c0a0;
opacity: 0.3;
}
.corner-decoration:nth-child(1) {
top: 20px;
left: 20px;
border-right: none;
border-bottom: none;
}
响应式调整
确保在不同设备上的显示效果:
@media (max-width: 768px) {
.letter {
width: 95%;
padding: 1.5rem;
}
.letter-body {
font-size: 1rem;
}
}
完整HTML结构
配合上述CSS的HTML基础结构:
<div class="letter">
<div class="corner-decoration"></div>
<div class="letter-header">
<div class="date">June 5, 2023</div>
<div class="address">
123 Main Street<br>
City, State 12345
</div>
</div>
<div class="letter-body">
<p>Dear Recipient,</p>
<p>This is the main content of your letter...</p>
</div>
<div class="letter-signature">
Sincerely,<br>
<span>Your Name</span>
<span class="signature-line"></span>
</div>
</div>
进阶效果
添加信纸纹理和打字机字体效果:
.letter {
background-image:
linear-gradient(to bottom, rgba(255,255,255,0.3) 0%, transparent 100%),
url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect fill="%23f9f5e9" width="100" height="100"/><path fill="%23e8e0d0" d="M0 0 L100 0 L100 1 L0 1 Z M0 99 L100 99 L100 100 L0 100 Z M0 49 L100 49 L100 50 L0 50 Z"/></svg>');
background-size: 100% 100%, 100px 100px;
}
.typewriter {
font-family: 'Courier New', monospace;
color: #222;
animation: typing 0.5s steps(40, end);
}
这些样式组合可以创建出具有复古风格的专业信件外观,可根据需要调整颜色、尺寸和装饰元素。






