效果展示
制作步骤
核心 CSS 属性mask
https://developer.mozilla.org/zh-CN/docs/Web/CSS/mask
1 2 3 4 5
| <div class="box"> <div class="content"> <div>5元 优惠券</div> </div> </div>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| .box { position: relative; width: 300px; height: 150px; filter: drop-shadow(0px 0px 1px rgba(0, 0, 0, 0.5)); } .box::before { content: ''; width: 100%; height: 100%; position: absolute; left: 0; top: 0; background: #fdb716; -webkit-mask: radial-gradient( circle at 20px 20px, transparent 20px, red 0 )-20px -20px /50% 100%, radial-gradient( circle at 5px 5px, transparent 5px, red 0 )-155px -5px/100% 9%; -webkit-mask-composite: source-in; } .box .content { position: absolute; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; color: #fff; font-weight: bold; font-size: 36px; }
|