3

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

  • Please add what you have tried here WITH the HTML as a working example to enable us to better assist you this may assist you in improving your question https://stackoverflow.com/help/asking As it stands we need to know the specifics of the problem - please note what is generic here as a posted example and what would change so we may give a great answer here. – Mark Schultheiss Apr 07 '19 at 13:00
  • Hi Mark. I just edited my question and I really don't know how to make my question any clearer.. I think the question is really straight forward. Answer might be a bit tricky if any though –  Apr 07 '19 at 14:06

2 Answers2

1

  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>
Kirito
  • 146
  • 2
  • 4
  • Hi there. Thanks for reply but I need to blur everything behind the container and not actual container. I have just edited my question so it might be clearer now –  Apr 07 '19 at 14:15
  • OK , i edit my code . when you type text in Text field , blur class added to a div for blur it , you can do something like this for your background! .Hope it work for you and sorry for bad English! .If you have any question, ask me – Kirito Apr 07 '19 at 15:06
  • Thanks. I actually already tried this approach however there are some downsides to this. The container might only cover half of the element or entire element depens on how many suggestions it have and also I would have to add the blur to everything it possibly can cover. I guess I will have to just leave it without blurring because I don't think there is any other decent solution for that therefore your answer to this question is correct. Thanks for your answer anyway –  Apr 07 '19 at 15:17
  • can you share your html , i think i can help – Kirito Apr 07 '19 at 15:20
  • Sorry I can not do it right now... The work is still in progress but I really appreciate your effort –  Apr 07 '19 at 15:24
0

This question speaks to blur Can you blur the content beneath/behind a div? There is also opacity going on there as well, here are some ugly things to demonstrate that.

This is somewhat difficult to answer as it does depend on your markup a bit - and CSS pure vs some JavaScript are in some cases very different. here are some things.

.my-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding: .4em;
  background: rgba(235, 235, 235, 0.8);
  border: none;
  border-radius: 0.5em;
  padding: 1em 2em 1em 1em;
  font-size: 1em;
}


/* the triagle arrow */

.select-container {
  position: relative;
  display: inline;
}


/* the triagle arrow */

.select-container:after {
  content: "";
  width: 0;
  height: 0;
  position: absolute;
  pointer-events: none;
}


/* the triagle arrow */

.select-container:after {
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  top: .3em;
  right: .75em;
  border-top: 8px solid black;
  opacity: 0.5;
}

.my-select::-ms-expand {
  display: none;
}

.my-select:focus {
  outline: none;
  border-radius: 0.5em;
}

select.my-select * {
  background: rgba(235, 235, 235, 0.8);
  opacity: 0.8;
  color: lightorange;
}

select.my-select * {
  background-color: #bbeeee;
  color: #226666;
  opacity: 8;
}

select.my-select *:focus {
  background: rgba(235, 135, 100, 0.5);
  opacity: 0.8;
}

.list-container>.my-list:hover {
  opacity: 0.6;
}

.list-container .my-list li:hover {
  color: lime;
  );
}

.something {
  font-size: 2em;
  position: relative;
  top: -0.7em;
  z-index: -2
}

.my-list {
  padding-top: 0.4em;
  background: rgba(240, 240, 200, 0.9);
  border: none;
  border-radius: 0.5em;
  padding: 1em 1.5em 1em 1em;
  font-size: 1.4em;
  border: solid 0.25px green;
}

.my-list li {
  color: #227777;
  list-style-type: square;
}

.other {
  color: red;
  font-size: 2em;
  background-color: lightblue;
  position: relative;
  top: -2.5em;
  left: 1px;
  height: 3em;
  z-index: -1;
}

.test-backdrop-container {
  height: 10em;
  border: 1px dotted red;
  font-size: 2em;
  position: relative;
}

.test-backdrop {
  position: relative;
  size: 1.5em;
  top: 0.75em;
  left: 0.75em;
  border: solid blue 1px;
  background-color: #dddddd;
}

.test-backdrop {
  -webkit-backdrop-filter: blur(10px);
  opacity: 0.8;
}
<div class="select-container">
  <select class="my-select">
    <option>one wider text</option>
    <option>two</option>
    <option>eagle</option>
    <option>canary</option>
    <option>crow</option>
    <option>emu</option>
  </select>
</div>
<div class="something">something here</div>
<div class="list-container">
  <ul class="my-list">
    <li>one wider text</li>
    <li>two</li>
    <li>eagle</li>
    <li>canary</li>
    <li>crow</li>
    <li>emu</li>
  </ul>
</div>
<div class="other">Tester out
  <input class="other-input" type="text" value="something in textbox" /> More is not more but not less
</div>
<div class="test-backdrop-container">Test Container
  <div class="test-backdrop">Test Backdrop</div>
  more text in container more test text
</div>
Mark Schultheiss
  • 32,614
  • 12
  • 69
  • 100
  • Hi Mark. Opacity and alpha in rgba is something I have already tried and it doesn't look very well. It would be nice to have something in css like "blur under container" feature what would make an effect of blurred background. I was hoping there is something in css what would do the job.. I'll check the other answers in similar question you have posted yet. Thanks –  Apr 07 '19 at 19:07