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

Incorporate the {{ }} syntax to implement the Function

Can a function, such as toLocaleLowerCase(), be used inside {{ }}? If not, is there an alternative method for achieving this? <div *ngFor="let item of elements| keyvalue :originalOrder" class="row mt-3"> <label class=" ...

Instructions on how to navigate to a class page by clicking a button in a ReactJS interface

I am currently working with React and have implemented 3 classes in separate files. The App.js file contains a navbar and button, which when clicked, displays a table from 'Table.js'. I have also added buttons in front of each row in the table th ...

The Nivo Slider is stealthily concealing my CSS Menu

Although this question has been previously asked, I am still unable to make it work with the solutions provided; The website in question is I have tried changing the z-index on all menu items to 99999, but they are still appearing below. <div id="sli ...

Unusual issue with horizontal menu display in Firefox on Mac

I recently completed a website project using Contao for a client (visit www.medivas.de). Everything is working perfectly except for one issue: the last menu item in the main navigation (located at the top, above the slideshow) is causing a line break. This ...

Altering the DOM directly within the componentDidMount() lifecycle method without needing to use

In ReactJS, I am facing an issue while trying to manipulate the DOM in the componentDidMount() method. The problem lies in the fact that the DOM is not fully rendered at this point, requiring me to use a setTimeout function, which I find undesirable. Upon ...

Applying CSS transition delays to multiple images

I'm having trouble implementing a transition delay in my CSS. I've tried adding it in various places but it doesn't seem to be working as expected. This is my CSS: .imageBox { position: relative; float: left; transition ...

Which is the preferable option for creating a circular daily planner: canvas or SVG?

As a novice programmer delving into the world of coding (or at least hoping to), I have a question regarding graphic tools in html5 for my latest project. My goal is to create a planner app using electron, with the unique twist that the planner form sho ...

Craft a unique parallax effect using Framer Motion's clipping feature

To help visualize my concept, I have sketched it out using Figma. This idea involves a slide transitioning between pages. The goal is to cover the entire page with a sliding effect, and then place a sticker (dubbed the Parallax Box) on top of it. However ...

When hovering over a select option, a description and clickable link will be displayed

I need to display a description with a clickable link when hovering over any option in the select tag. <div class="col-lg-4"> <div class="form-group"> <label class="form-label">Goal</label> <select name="semiTaskType ...

My custom class is being ignored by Tailwind CSS within breakpoints

I'm attempting to incorporate some animation on the height property within the md breakpoint, but for some reason Tailwind CSS isn't applying my class. <div className={`h-12 bg-blue flex w-full text-white fixed mt-1 md:bg-white ${scrolling ? ...

Is there a way to set an image as the background of my HTML screen?

{% extends "layout.html" %} {% block app_content %} <div> {% from "_formhelpers.html" import render_field %} <form method="post" enctype="multipart/form-data"> <div class = "container"> < ...

Tips for setting environmental variables to match ID values in html documents

In my API reference call, I have stored the key in a separate file and protected it using .gitignore since I am using GitHub. However, I am facing an issue on how to transfer that key from my JavaScript file into the HTML data-key attribute using a variab ...

Can we execute a function once a mandatory field in a form has been validated successfully?

Looking for a way to execute a function after validating required inputs in a form before submission. Any suggestions? And I'm specifically not using jQuery, but Angular ...

As the text in the textarea grows, the dimensions of the div containing it will

When text is entered in the div, its height increases accordingly. However, I would like the height to also adjust based on the size of the text when I press enter. Additionally, I need the width to remain constant until the text reaches the maximum width ...

Is it possible for jQuery UI Dialog to function similar to an iFrame?

Is there a way to set up my dialog box with a form so that when the form is submitted, only the dialog box changes instead of the browser location? ...

Customizing Paths in Express Handlebars

I have a query regarding setting up custom folders in Express.js Here's my situation: I need to implement logic where if a specific name is present in my database, the paths for CSS and JS files should be altered before rendering. By default, my pat ...

Verify role declarations and display components if valid

I am currently developing an application using Angular on the front-end and ASP.NET on the back-end. Within this application, there are two roles: user and admin. I have implemented a navigation bar with several buttons that I need to hide based on the use ...

What is the best way to move the Grid upward when the above content is not visible?

Let me demonstrate what I have been working on. Currently, I am creating a weather application to explore the functionalities of https://material-ui.com/. I am attempting to prototype an animation inspired by Google Flights, which can be seen here: https: ...

"Enhance your ASP.NET site with a captivating background

I am currently working with C# in VS2005. My challenge is to add a background image to my login page, which is in the form of an .aspx file. Here is a screenshot of my current setup: Here is the code snippet for my background: <div align="center" ...

Creating a WordPress Infographic: How to Design a "Wide" Graphic

I have a question for those who are experienced with infographics. I'm in the process of getting an infographic designed for my blog and I've noticed that some websites have a feature that allows the infographic to expand to full width when you c ...