答案 0 :(得分:1)
你可以用渐变来做到这一点。只需调整图像比例的渐变。
.image {
display:inline-block;
position: relative;
width:100%;
}
.image img {
position: relative;
z-index: 1;
width:100%;
}
.image:after {
position:absolute;
content: '';
display: inline-block;
width: 100%;
height: 100%;
bottom: 4px;
left: 0;
z-index: 2;
background: linear-gradient(33.5deg, rgba(255, 50, 54, 0.5) 0%, rgba(255, 26, 28, 0.5) 49.9%, rgba(255, 25, 27, 0) 50%, rgba(255, 0, 0, 0) 100%);
}
<div class="image">
<img src="https://images.pexels.com/photos/257360/pexels-photo-257360.jpeg?auto=compress&cs=tinysrgb&h=350" alt="">
</div>
答案 1 :(得分:0)
一个简单的linear-gradient
,你得到了它:
.box {
height:300px;
background:
linear-gradient(to bottom left,transparent 50%,rgba(255,0,0,0.8) 50.5%),
url(https://picsum.photos/2000/1000?image=1069) center/cover no-repeat;
}
&#13;
<div class="box">
</div>
&#13;
用简单的图像:
.box {
position: relative;
}
.box img {
width:100%;
display:block;
}
.box:before {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 2;
background: linear-gradient(to bottom left, transparent 50%, rgba(255, 0, 0, 0.8) 50.5%);
}
&#13;
<div class="box">
<img src="https://picsum.photos/500/200?image=1069">
</div>
&#13;