0

div {
  width: 100px;
  height: 100px;
  background: red;
  transition: width 2s linear 1s;
}

div:hover {
  width: 300px;
}
.layer1{
    transition: 1s;
}

.layer2{
    transition : 1s;
}

.layer1:hover ~ .layer2 {
    filter: blur(10px)
}

.layer1:hover {
    box-shadow: 0 25px 60px rgba(0,0,0,.8);
}
<h1 class="layer1 layer2">Using The transition Shorthand Property</h1>

<p class="layer1 layer2">Hover over the div element below, to see the transition effect:</p>

<div class="layer1 layer2"></div>

<p class="layer1 layer2"><b>Note:</b> The transition effect has a 1 second delay before starting.</p>

<p class="layer1 layer2"><b>Note:</b> This example does not work in Internet Explorer 9 and earlier versions.</p>

codepen

I have multiple elements in a page, and i want to add blur affect. when i hover in the top element every other element is getting blurred(which is correct). But when i hover over the second element, the element above it is not getting blurred, but the elements below it is blurred.

Kindly provide me a solution for this problem.

G-Cyrillus
  • 101,410
  • 14
  • 105
  • 129
Krish
  • 23
  • 8

1 Answers1

0

I came up with a solution. Changed the classes and identifiers though.

Here is the HTML:

<div class=content>
<h1 class="element">Using The transition Shorthand Property</h1>
<p class="element">Hover over the div element below, to see the transition effect:</p>
<div id="widen" class="element"></div>

<p class="element"><b>Note:</b> The transition effect has a 1 second delay before starting.</p>

<p class="element"><b>Note:</b> This example does not work in Internet Explorer 9 and earlier versions.</p>
</div>

And the CSS:

    #widen {
    background: red;
    width: 100px;
    height: 100px;
    transition: width 2s linear 1s;
    }

    #widen:hover {
    width: 300px;
    }

    .element:hover, #widen:hover {
    transition: 1s;
    box-shadow: 0 25px 60px rgba(0, 0, 0, .8);
    }

    .content:hover .element {
    filter: blur(5px);
    }

    .content .element:hover {
    filter: blur(0);
    }
Jane. D
  • 23
  • 6
  • 1
    Good idea, but we must make sure that our `.element`s should fit their parent.Otherwise hovering on any white space area will cause all elements to blur . – AbbasEbadian Aug 23 '20 at 11:21
  • This is a potential solution. But I have used JS for this purpose. https://codepen.io/krish-barman/pen/ExKZgXN – Krish Aug 23 '20 at 11:44