1 回答
TA贡献1946条经验 获得超4个赞
这可以使用掩模来完成。
这是一个简化的示例:
.box {
height:60vh;
font-size:50px;
text-align:center;
color:#fff;
position:relative;
z-index:0;
}
.box:before {
content:"";
position:absolute;
z-index:-1;
left:0;
right:0;
top:-50px;
bottom:-50px;
background:var(--img) center/cover;
-webkit-mask:linear-gradient(transparent ,#fff 50px calc(100% - 50px),transparent);
mask:linear-gradient(transparent ,#fff 50px calc(100% - 50px),transparent);
}
<div class="box" style="--img:url(https://picsum.photos/id/1002/800/800.jpg)">text 1</div>
<div class="box" style="--img:url(https://picsum.photos/id/109/800/800.jpg)">text 2</div>
<div class="box" style="--img:url(https://picsum.photos/id/107/800/800.jpg)">text 3</div>
<div class="box" style="--img:url(https://picsum.photos/id/177/800/800.jpg)">text 4</div>
- 1 回答
- 0 关注
- 104 浏览
添加回答
举报