Blurring the background creates an "inset shadow" problem when transitioning

Problem:

Strangely, when using Backdrop-filter: blur(Xpx); during a transition as shown below, unexpected "inset Shadows" mysteriously appear until the end of the transition.

https://i.stack.imgur.com/uij7F.gif

Illustration of the Issue Using jsfiddle

Specifications:

  • Chrome Version: 83
  • OS: Windows 10

Conclusion:

Any insights?
Thank you in advance.. (:

- [ Update 23/6/2020 ]:

Finally discovered a workaround for those who may require something specific. However, it does not address my issue regarding background elements [...]

- [ Update 1/7/2021 ]:

Issue resolved on Chrome Version: 91.0.4472.114

Answer №1

Welcome.

Hey there, what you're going through is not uncommon. This is how the backdrop-filter style rule functions based on W3C standards*. When combined with the transition style rule and no background, it results in the issue you are facing.

Solution and Coding Tips.

Before we delve into the solution, I must mention that I advise against using the backdrop-filter due to its limited support, as indicated by a reputable source*. Instead, consider utilizing the filter rule which enjoys broader support*

Now, let's address some coding errors and provides fixes for your problem:

body{
background-image: url("https://i.pinimg.com/originals/d2/64/ce/d264ce996ff6531fe191dfce5b200b3a.jpg");
background-position: center; 
background-repeat: no-repeat;
background-color:yellow;
}

#el{
position:fixed;
top:14px;
left:14px;
right:14px;
bottom:14px;

-webkit-transition: all 7s;
-moz-transition: all 7s;
-o-transition: all 7s;
transition: all 7s;


}

#el.changeState{
-webkit-backdrop-filter:blur(7px);
backdrop-filter:blur(7px);
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>


<button onclick="Clicked()">Blur Me (:</button>
<script>
function Clicked() {
  var el = document.getElementById('el');
  
  el.innerHTML = ":O";
  el.classList.add('changeState');
}
</script>

<p id="el"></p>

</body>
</html>

To improve this code:

(function addBlurEffect() {

  const d = document;

  function getId(id) {
    return d.getElementById(id);
  }

  let emptyParagaphTag = getId(`addTextTo`);
  let button = getId(`listeningToButton`);

  
  button.addEventListener(`click`, function stateClicked() {
      this.innerHTML = `:O`;
      emptyParagaphTag.classList.add(`changeState`);

      // No overflows ;)
      button.removeEventListener(`click`, stateClicked);
  });
})();

// In my opinion, this Javascript code is much cleaner!
body {
  background-image: url("https://i.pinimg.com/originals/d2/64/ce/d264ce996ff6531fe191dfce5b200b3a.jpg");
  background-position: center; 
  background-repeat: no-repeat;
  background-color: yellow; /* This wouldn't work... since it wold be covered.. I don't understand what you want with that, other than getting blinded? */
}

#addTextTo {
  position:fixed;
  top:14px;
  left:14px;
  right:14px;
  bottom:14px;

  -webkit-transition: all 7s;
  -moz-transition: all 7s;
  -o-transition: all 7s;
  transition: all 7s;
  
  background: rgba(255, 255, 255, 0.4); /* You forgot to add this! */
}

.changeState {
  filter: blur(7px); /* Much better! */
}
<!DOCTYPE html>
<html lang="en-us">
<head>
  <title>Example</title>
</head>
<body>

<!-- HTML code is free to breath now, nothing to be clogged here. -->
<button id="listeningToButton">Click to Blur (:</button>
<p id="addTextTo"></p>

</body>
</html>

Final Thoughts.

I hope this information has been helpful in resolving your issue and clarifying any confusion. Feel free to ask questions regarding any aspect of the code.

References.

(*) = Important Links!

W3C => https://www.w3.org/TR/filter-effects-1/#supported-filter-functions

CanIUse backdrop-filter (not recommended) => https://caniuse.com/#search=backdrop%20filter

CanIUse filter (recommended) => https://caniuse.com/#search=CSS%20Filter%20Effects

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Taking control of Bootstrap with Kajiki customization

I need to replace this particular table with a Bootstrap table (striped-table). Even though I attempted to directly modify the tags, it didn't yield the desired results. What should be the correct approach for achieving this change? ...

Is a Selenium loop a viable option?

</head> <body> <table cellpadding="1" cellspacing="1" border="1"> <thead> <tr><td rowspan="1" colspan="3">test</td></tr> </thead><tbody> <tr> <td>click& ...

Troubleshoot padding problems in mpdf

Note: mpdf 6.0 Greetings, In my efforts to produce precise PDFs using mpdf for future printing purposes, I have encountered an issue with the positioning of elements on the page. I require these elements to be positioned precisely from the top left corne ...

using javascript to change a link's state with a click action

I have a question that is related to the topic discussed here: Making a link stay active displaying hover effect upon click using javascript. I am looking for a way to disable the active class when the same link is clicked again. Any assistance on this mat ...

What is the purpose of the video-js endcard plugin incorporating native controls into the player?

Endcard is a unique plugin designed for the video-js html5 video player that adds clickable links to the end of a video. (More information on endcards can be found here: https://github.com/theonion/videojs-endcard). To implement an endcard, simply include ...

Using jQuery to modify CSS attributes is proving to be more challenging than I anticipated

I am attempting to modify a CSS attribute using jQuery. I have used the following code: wrapperInner.css('overflow', 'visible'); However, the value remains unchanged. When I use an alert alert(wrapperInner.css('overflow')), ...

Having trouble with React image rendering using webpack?

Struggling to display an image in my React Web App, I encountered a broken image despite the correct file path appearing in the console log. We're utilizing url-loader and file-loader with webpack, importing the file path directly as necessary. Attemp ...

The Bootstrap carousel indicators are not automatically switching because they are placed outside of the main div

I have integrated the latest Bootstrap framework into my website, featuring a visually appealing carousel. The unique aspect of my carousel design is that the indicators are positioned outside the main carousel div. Here is a snippet of my carousel code: ...

Guide on adjusting image dimensions in JTextPane using HTML and CSS in the Java Swing environment

I am looking to add an image (such as a formula created from LaTeX) into JTextPane, using HTML+CSS for text formatting and manually setting its size. I attempted the following approach: import java.awt.Dimension; import javax.swing.JFrame; import javax.swi ...

Adding a <span> element within an <h1> tag in WordPress

I am attempting to create this layout in Wordpress using the code <h1>This is my <span>title</span></h1>, but I am unsure how to incorporate a <span> tag within the <?php the_title(); ?> function. After consulting the c ...

In need of styling text using CSS?

Despite setting the CSS to .text { word-wrap : break-word; max-width: 100px}, the text is not wrapping as expected. It is still displaying in a single line. I am anticipating that the large text should wrap onto the next lines. ...

Utilizing JavaScript to display numerous variables within a text box

After creating an HTML form, I encountered an issue where only one selected item was displayed in the text field. Can anyone help me solve this problem so that multiple names can be printed in the textfield? function myFun(extras) { document.get ...

Achieving Equal Heights for Nested DIVs within Containers

Below is the snippet of code I need help with: <table cellpadding="0" cellspacing="0" style="background-color:Aqua"> <tr> <td> <div style="background-color:Yellow">Navigation</div> </td> ...

centering headers using tailwind styles

I am facing a challenge with positioning my main title, logo, and subtitle. I want the subtitle to be centered regardless of the logo's width. Currently, the position of the sub title changes based on the logo's width, resulting in it not aligni ...

Steps for incorporating universal style into Angular 6/7 library

I attempted to incorporate global styles in my Angular app similar to how it's done, but unfortunately, it didn't work as expected. The library I'm using is named example-lib. To include the styles, I added styles.css in the directory /proj ...

I'm having trouble making the colors change on my Icon font/sprite rollover

I am currently attempting to position some related icons above my main navigation menu. The goal is to change the text and icon colors when a user hovers over a specific area (the tag with large padding). Unfortunately, I am facing challenges in achieving ...

Utilizing static HTML, CSS, and JavaScript for secure backend administrative control

Seeking a solution for my static html, CSS, and JS website which includes some Jquery elements. I want to implement a user-friendly backend system that allows non-developer admins to log in, easily edit sections or change images with their own preferences. ...

Could the issue lie with PHP or the caching system?

I'm encountering a frustrating issue with my simple test that I just can't seem to resolve. It seems like there's some sort of glitch involving images and PHP, as I can only display one image at a time. The script looks correct to me, so I&a ...

Attempting to preserve the CSS transform effect as I switch between menu options

Whenever I stop hovering over my element, it reverts back to its original position. However, I want it to remain in place when I am navigating through the "sousmenu" menu and only return to its original position when I am not hovering over the "sousmenu". ...

CSS - Ensuring that the height of one div extends all the way down to meet another div

I'm facing an issue with two divs in my design. One of them contains a checkbox and the other has text which can vary in size - sometimes it's small, sometimes it's large. When the text in the second div is big, the box on the left extends a ...