答案 0 :(得分:2)
这是我的方法,如何处理这项任务。我使用伪元素:之前和:之后与transform: skewX(deg)
和border-left
属性。
这是代码片段:
.bg-arrow {
display: flex;
justify-content: flex-end;
background:url('http://wallpaperlepi.com/wp-content/uploads/2014/10/Stone-And-Star-Wallpaper.jpg') #ddd center center no-repeat;
background-size: cover;
}
.arrow-shape{
position: relative;
display: flex;
align-items: center;
justify-content: space-around;
width: 200px;
height: 100px;
background-color: #fff;
}
.arrow-shape:before,
.arrow-shape:after{
content: '';
position: absolute;
left: 0;
height: 50%;
width: 100%;
background-color: #fff;
border-left: 4px solid #000;
z-index: 1;
}
.arrow-shape:before {
top: 0;
transform: skewX(15deg) translateX(-30px);
}
.arrow-shape:after {
transform: skewX(-15deg) translateX(-30px);
bottom: 0;
}
.arrow-shape .text {
position: relative;
text-align: center;
z-index: 2;
}

<div class="bg-arrow">
<div class="arrow-shape">
<div class="text">
Lorem ipsum dolor sit amet consectetur.
</div>
</div>
</div>
&#13;
答案 1 :(得分:1)
这是一个元素,多个背景和更少代码的另一个想法:
.box {
padding: 50px 30px;
text-align: right;
background-image:
linear-gradient(60deg,transparent 70%,#000 70%,#000 71%,#fff 71%),
linear-gradient(120deg,transparent 70%,#000 70%,#000 71%,#fff 71%),
url(https://picsum.photos/2000/1000?image=1069);
background-position:top right,bottom right,center;
background-size:600px 50%,600px 50%,cover;
background-repeat:no-repeat;
}
&#13;
<div class="box">
some text here<br> more text
</div>
&#13;