css background 优惠券
背景渐变 优惠券
by 142536yu
HTML
<div class="box">
<details open>
<summary>
第一种 原形镂空
</summary>
<div class="c-style-1"></div>
</details>
<details open>
<summary>
第二种 连续镂空
</summary>
<div class="c-style-1 c-style-2"></div>
</details>
<details>
<summary>
原图
</summary>
<img src="http://img95.699pic.com/element/40118/4001.png_860.png" alt="">
</details>
<details open>
<summary>
实现
</summary>
<div class="coupons-wrap lacework">
<div class="coupons-name">
<span>20元</span>
<p>优惠券</p>
</div>
<p class="coupons-line"></p>
<div class="coupons-info">
<p class="coupons-info-name">优惠券减 20</p>
<p style="font-size: 20px;">满 50 元可用</p>
</div>
</div>
</details>
</div>
CSS
* {
margin: 0;
padding:0;
}
img {
width: 400px;
height: 400px;
display: block;
margin: 50px auto;
}
.box {
margin: 100px auto;
}
.box div { margin: auto }
details {
text-indent: 20px;
margin: 20px 0;
}
summary {
outline: none;
}
.c-style-1 {
position: relative;
width: 300px;
height: 150px;
margin-top: 20px;
background: radial-gradient(circle at top right, transparent 13px, #f26f4c 0) left top / 51% 50% no-repeat,
radial-gradient(circle at bottom right, transparent 13px, #f26f4c 0) left bottom / 51% 50% no-repeat,
radial-gradient(circle at left top, transparent 13px, #f26f4c 0) right top / 51% 50% no-repeat,
radial-gradient(circle at left bottom, transparent 13px, #f26f4c 0) right bottom / 51% 50% no-repeat;
filter: drop-shadow(2px 2px 2px rgba(0,0,0,.2));
/*background-origin: content-box;*/
}
.c-style-2:after {
content: "";
position: absolute;
top: 0;
bottom: 0;
right: -11px;
width: 11px;
/*background-color: #5cb85c;*/
background-image: linear-gradient(to bottom, #f26f4c 0px, transparent 5px, transparent),
radial-gradient(circle at 10px, transparent 5px, #f26f4c 5px);
background-repeat: repeat;
background-size: 11px 15px;
}
.coupons-wrap {
text-indent: 0;
margin: auto;
display: flex;
justify-content: space-between;
/*764 40%*/
width: 305px; /*减去两边的花边 17px(未换算)*/
height: 132px;
padding-top: 6px;
padding-left: 6px;
position: relative;
background: radial-gradient(circle at top right, transparent 11px, #f26f4c 0) left top / 99px 66px no-repeat,
radial-gradient(circle at right bottom, transparent 11px, #f26f4c 0) left bottom / 99px 66px no-repeat,
radial-gradient(circle at left top, transparent 11px, #f26f4c 0) right top / 206px 66px no-repeat,
radial-gradient(circle at left bottom, transparent 11px, #f26f4c 0) right bottom / 206px 66px no-repeat;
...