Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply a CSS blur filter to a background (not image)

Tags:

css

I got autocomplete dropdown filled with almost solid background colour

.Suggestions {
  text-align: left;
  position: absolute;
  border: 1px solid #ddd;
  border-radius: 5px;
  background-color: rgba(235, 235, 235, 0.95);
  list-style: none;
  margin-top: -9px;
  max-height: 143px;
  overflow-y: auto;
  padding-left: 0;
  width: 406px;
}

covering other elements (buttons, inputs ...) when activated

DEACTIVATED enter image description here

ACTIVATED enter image description here

and I would like to make an effect similar to safari dropdown when clicked on url where everything behind is almost visible and also blurred.

enter image description here

Is there any way to do that in css? I know that I can create an image and then apply blur filter but the autocomplete is used in many screens with different background so creating image for each screen would be a mammoth task


1 Answers

  function myFunction() {
    var Textfield  = document.getElementById("Textfield");
   
    if (Textfield.value == "")
      document.getElementById("back_div").classList.remove("blur");
    else
      document.getElementById("back_div").classList.add("blur");

  }
 .blur {
      /* Add the blur effect */
      filter: blur(2.5px);
      -webkit-filter: blur(2.5px);
    }
  <input id="Textfield" onkeyup="myFunction()" type="text">
  <div id="back_div">test text</div>
like image 82
Meysam maboudi Avatar answered Dec 12 '25 12:12

Meysam maboudi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!