css - 拉伸模糊的图像边
问题描述
我想让我的 div 有模糊的一面
我尝试将图像添加为 div 中的背景并使其居中两侧为白色,我希望它们具有拉伸模糊效果
背景:url(image.jpeg) 无重复中心中心;
我想要类似预期的代码:背景:25% 向右模糊,25% 向左模糊,url(image.jpeg) no-repeat center center;
预期输出:
原始图像: 在此处输入图像描述
解决方案
试试这个,如果你有一个高分辨率图像,然后用那个替换 css(.bg-image) 背景图像
.bg-image {
background-image: url(https://i.stack.imgur.com/KGa2E.png);
filter: blur(8px);
-webkit-filter: blur(8px);
height: 100%;
background-position: left bottom;
background-repeat: no-repeat;
background-size: cover;
transform: scale(1.5);
}
/* Position text in the middle of the page/image */
.bg-text {
color: white;
font-weight: bold;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 2;
width: 80%;
padding: 20px;
text-align: center;
}
<div class="bg-image"></div>
<div class="bg-text">
<img src="https://i.stack.imgur.com/KGa2E.png">
</div>
推荐阅读
- vue.js - 使用 Vue Test Utils 将模拟方法传递给 mount/shallowMount
- c++ - 将状态存储在 c++ dll 中
- angular - Consistent Height on Angular material tabs
- angular - 使用 takeUntil() 关闭订阅
- c++ - 即使我正在移动,编译器也会尝试使用复制构造函数
- angular - PrimeNg with Angular 7. Mistake with @angular/animation
- c# - NPoco 中是否有任何内置函数可用于在没有查询连接的情况下应用连接
- python - 从向量列表中查找所有可能的组合
- c# - 如何使用 Postman 上的 POST 请求将数据插入到多个表中?
- python - 如何读取多个文件并找到文件之间的差异?