我正在尝试创建它:
Image with slanted square overlay
我无法保持一点倾斜。我可以通过更改边界来实现一个三角形,但是它倾斜得太多了。
这是我的带有正方形和文字的图片代码:
cpu: "2"
.realtor-img-background {
height: 400px;
width: 450px;
background: url("./images/real-estate.jpg");
}
.square{
position: absolute;
bottom:0;
height: 200px;
width: 450px;
background-color: red;
}
答案 0 :(得分:2)
您可以在Border的帮助下使用CSS伪元素来创建此形状
.realtor-img-background {
height: 400px;
width: 450px;
position: relative;
background: url("http://via.placeholder.com/350x150") no-repeat top center;
background-size: cover;
}
.square {
position: absolute;
bottom: 0;
background-color: red;
}
.square:before {
content: "";
position: absolute;
left: 0;
top: -100px;
border-style: solid;
z-index: 1;
width: 0;
height: 0;
border:0;
border-bottom: 100px solid red;
border-right: 450px solid transparent;
}
<div class="realtor-img-background">
<div class="square">
<h3 class="eva-text-white">
Realtors
</h3>
<p class="eva-text-white">
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
</p>
</div>
</div>