【问题标题】:Image sides blurred by stretching拉伸模糊的图像边
【发布时间】:2019-09-30 21:39:53
【问题描述】:

我想让我的 div 有模糊的边

我尝试将图像作为背景添加到 div 中并使其居中两侧为白色,我希望它们具有拉伸模糊效果

背景:url(image.jpeg) 无重复中心;

我想要类似的东西 预期代码: 背景:右边25%模糊,左边25%模糊,url(image.jpeg)无重复中心;

预期输出:

enter image description here

原图: enter image description here

【问题讨论】:

    标签: css image background-image


    【解决方案1】:

    试试这个,如果你有一个高分辨率的图像,然后用那个替换 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>

    【讨论】:

    • 谢谢,这就是我所需要的!
    • 是否可以仅使用单个图像 url 做到这一点?
    • 为此,您需要在 Photoshop 中创建具有模糊效果的图像,然后您可以从 css 中删除背景图像
    猜你喜欢
    • 2013-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-11
    • 2014-03-29
    • 2023-03-17
    • 2017-03-24
    相关资源
    最近更新 更多