css优惠劵制作
使用CSS制作优惠券效果
通过CSS的边框、阴影和伪元素可以创建出吸引人的优惠券效果。以下是一个典型的优惠券样式实现方法:
<div class="coupon">
<div class="coupon-content">
<h3>特别优惠</h3>
<p>使用本券可享受8折优惠</p>
</div>
</div>
.coupon {
width: 300px;
height: 150px;
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
border-radius: 10px;
position: relative;
overflow: hidden;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.coupon::before {
content: "";
position: absolute;
top: 0;
left: 20%;
width: 60%;
height: 100%;
border-left: 2px dashed white;
border-right: 2px dashed white;
}
.coupon-content {
padding: 20px;
text-align: center;
color: #333;
}
.coupon h3 {
font-size: 24px;
margin-bottom: 10px;
}
.coupon p {
font-size: 16px;
}
添加锯齿边缘效果
要实现更真实的优惠券边缘效果,可以使用伪元素创建锯齿边缘:
.coupon {
position: relative;
background: #ff6b6b;
padding: 20px;
color: white;
}
.coupon::before,
.coupon::after {
content: "";
position: absolute;
height: 20px;
width: 100%;
left: 0;
background: repeating-linear-gradient(
45deg,
transparent,
transparent 10px,
white 10px,
white 20px
);
}
.coupon::before {
top: 0;
transform: translateY(-50%);
}
.coupon::after {
bottom: 0;
transform: translateY(50%);
}
添加撕线效果
优惠券常见的撕线效果可以通过CSS实现:
.coupon {
position: relative;
background: #fff;
border: 1px dashed #ccc;
}
.coupon::after {
content: "";
position: absolute;
top: 50%;
left: 0;
right: 0;
height: 2px;
background: repeating-linear-gradient(
to right,
transparent,
transparent 5px,
#ccc 5px,
#ccc 10px
);
transform: translateY(-50%);
}
响应式优惠券设计
为了使优惠券在不同设备上都能良好显示,可以添加响应式设计:

.coupon {
max-width: 100%;
margin: 0 auto;
}
@media (min-width: 768px) {
.coupon {
width: 350px;
}
}
这些CSS技巧可以组合使用,创建出各种风格的优惠券效果。根据实际需求调整颜色、尺寸和样式细节,可以达到理想的视觉效果。






