Reputation: 2992
As it's quite difficult to explain, I'll show you an image of what I pretend.
The problem is not the "triangle", but the image background to be shown in that "space" that triangle generates.
Upvotes: 0
Views: 35
Reputation: 274374
Here is another idea with one element, multiple background and less of code:
.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;
}
<div class="box">
some text here<br> more text
</div>
Upvotes: 1
Reputation: 2463
Here is my approach, how to deal with this task. I use pseudo elements :before and :after with transform: skewX(deg)
and border-left
properties.
Here is code snippet:
.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>
Upvotes: 2