gpt4 book ai didi

html - 模糊图像的一侧

转载 作者:行者123 更新时间:2023-12-04 09:48:05 24 4
gpt4 key购买 nike

如何模糊图像的一侧以创建从图像到背景的良好过渡?

我能够通过这个小技巧做到这一点:

.wrapper {
width: 200px;
height: 250px;
overflow: hidden;
}
.image-blurred {
background-image: url('http://lorempixel.com/200/200/city/9');
width: 200px;
height: 200px;
filter: blur(15px);
position: relative;
}

.frontimage {
position: absolute;
top:0px;
-webkit-mask-image: -webkit-gradient(linear, left top, left bottom,
from(rgba(0,0,0,1)), to(rgba(0,0,0,0)));
}
<div class="wrapper">
<div class="image-blurred"></div>
<div class="frontimage"><img src="http://lorempixel.com/200/200/city/9"></div>
</div>


但是 -webkit-mask-image不是一个可靠的选择。

有没有其他方法可以实现这一目标?

最佳答案

你需要正确写掩码,它是可靠的https://caniuse.com/#feat=css-masks (仅不支持 IE,这并不奇怪)

您还可以简化您的代码,如下所示:

.frontimage img {
filter: blur(15px);
}
.frontimage {
position:relative;
display:inline-block;
padding-bottom:50px;
overflow: hidden;
}

.frontimage::after {
content:"";
position:absolute;
background-image: url('http://lorempixel.com/200/200/city/9');
top: 0;
left:0;
right:0;
bottom:50px;
-webkit-mask-image: linear-gradient(to bottom, #fff, transparent);
mask-image: linear-gradient(to bottom, #fff, transparent);
}
<div class="frontimage">
<img src="http://lorempixel.com/200/200/city/9">
</div>


获得不同效果的相关问题: Mask Image, create rectangle from multiple gradients

关于html - 模糊图像的一侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62051623/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com