Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select2 dropdown are floating #313

Closed
justkidding96 opened this issue Apr 30, 2021 · 1 comment
Closed

Select2 dropdown are floating #313

justkidding96 opened this issue Apr 30, 2021 · 1 comment

Comments

@justkidding96
Copy link

I've an issue that my dropdown from Select2 are floating when I scroll to the page. I think this issue caused that select2 creates an element outside the scroll-content div.

@sadeghbarati
Copy link
Collaborator

@justkidding96

https://stackblitz.com/edit/github-urgjn6?file=src/index.html

Have you tried select2 dropdownParent option?

<div id="select2Wrapper" class="position-relative">
 <select class="js-example-basic-single w-100">
    <option value="AL">Alabama</option>
    <option value="WY">Wyoming</option>
  </select>
  
  <!-- dropdown will append inside of #select2Wrapper -->
</div>

<script>
  window.addEventListener('load', function () {
    $('.js-example-basic-single').select2({
      dropdownParent: $('#select2Wrapper'),
    });
  });
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants