blur of part of Background image with css

前端 未结 2 1526
暖寄归人
暖寄归人 2020-11-30 07:19

I use this Is it possible to use -webkit-filter: blur(); on background-image? solution to make blurry backgroung image and it works great! But I want to make some <

相关标签:
2条回答
  • 2020-11-30 07:24

    use -webkit-filter: blur(2px) in .background div not in .content div.

    Here is your updated code:

    .content{
    width: 70%;
    height: 70%;
    border:2px solid;
    border-radius:20px;
    position: fixed;
    top: 15%;
    left: 15%;
    z-index:10;
    background-color: rgba(168, 235, 255, 0.2);
    filter: blur(2px); 
    -moz-filter: blur(2px);
    -o-filter: blur(2px); 
    -ms-filter: blur(2px);
    }
    
    .background{
    width:100%;
    height:100%;
    background-image:url('http://www.travel.com.hk/region/time_95.jpg');
    z-index:0;
    position:absolute;
     -webkit-filter: blur(2px);
    }
    
    0 讨论(0)
  • 2020-11-30 07:38

    If it has to be dynamic, you should have some trouble, but you can have somewhere to start with this :

    HTML

    <div class="background"></div>
    <div class="mask">
        <div class="bluredBackground"></div>
    </div>
    <div class="content"></div>
    

    CSS

    .content {
        width: 70%;
        height: 70%;
        border:2px solid;
        border-radius:20px;
        position: fixed;
        top: 15%;
        left: 15%;
        z-index:10;
        background-color: rgba(168, 235, 255, 0.2);
    }
    .background {
        width:100%;
        height:100%;
        background-image:url('http://www.travel.com.hk/region/time_95.jpg');
        z-index:2;
        position:fixed;
    }
    .bluredBackground {
        width:100%;
        height:100%;
        display:block;
        background-image:url('http://www.travel.com.hk/region/time_95.jpg');
        z-index:1;
        position:absolute;
        top:-20%;
        left:-20%;
        padding-left:20%;
        padding-top:20%;
        -webkit-filter: blur(2px);
    }
    .mask {
        width: 70%;
        height: 70%;
        border:2px solid;
        border-radius:20px;
        position: fixed;
        top: 15%;
        left: 15%;
        z-index:10;
        overflow:hidden;
    }
    

    FIDDLE

    0 讨论(0)
提交回复
热议问题