Search code examples
javascripthtmlcssmaterialize

How to get an Overlap with the Materialize.css Framework Autocompletion


So in my current project U use the Autocompletion from Materialize.css, I also made a quick example below so you can see my problem.

Whenever the results of the Autocomplete get shown the stuff below gets pushed down, I want to prevent that, since it looks ugly and the input on my page is right above other stuff and I don't want to move like that.

Would appreciate any help how I can achieve that goal.

The Materialize.css Autocomplete Docs

$(document).ready(function() {
  $('input.autocomplete').autocomplete({
    data: {
      "Apple": null,
      "Microsoft": null,
      "Google": 'https://placehold.it/250x250'
    },
    limit: 20, // The max amount of results that can be shown at once. Default: Infinity.
    onAutocomplete: function(val) {
      // Callback function when value is autcompleted.
    },
    minLength: 1, // The minimum length of the input for the autocomplete to start. Default: 1.
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css" rel="stylesheet" />
<div class="row">
  <div class="col s12">
    <div class="row">
      <div class="input-field col s12">
        <input type="text" id="autocomplete-input" class="autocomplete">
        <label for="autocomplete-input">Autocomplete</label>
      </div>
    </div>
  </div>
  <div class="col s12">
    This is my Example Div
    <br> lALLALALALAALA <br> lALLALALA
  </div>
</div>


Solution

  • try this:

    .autocomplete-content {
      position: absolute;
    }