selectize drop item to get in front always
Asked Answered
V

6

5

hello all i am using selectize plugin to create tags to my site everything is good except that the drop down item gets overlapped by my other divs.

i want them to behave like select items which are absolute and always in frnt.

i have tried positioning with absolute and z-index but no help if you could suggest me something about the plugin it would be great.

     <script src="tags/selectize.js"></script>
    <link rel="stylesheet" href="tags/selectize.default.css"/>
 <div class="control-group">
                <select id="<?=$getid_i?>" multiple name="dept[]" class="demo-default" >
                    <option value=""><?=$placehol?></option>
                    <?php if ($tagwhats =='depts'){
                 // something to get ....
                } else if($tagwhats =='skills'){
                 // something here ...
                } ?>
                </select>
            </div>
 <script>
                var eventHandler = function(name) {
                return function() {
                    console.log(name, arguments);
                    $('#log').append('<div><span class="name">' + name + '</span></div>');
                };
            };
            var $select = $('#'+"<?=$getid_i?>").selectize({
                create          : true,
                onChange        : eventHandler('onChange'),
                onItemAdd       : eventHandler('onItemAdd'),
                onItemRemove    : eventHandler('onItemRemove'),
                onOptionAdd     : eventHandler('onOptionAdd'),
                onOptionRemove  : eventHandler('onOptionRemove'),
                onDropdownOpen  : eventHandler('onDropdownOpen'),
                onDropdownClose : eventHandler('onDropdownClose'),
                onFocus         : eventHandler('onFocus'),
                onBlur          : eventHandler('onBlur'),
                onInitialize    : eventHandler('onInitialize'),
                });
                </script>
Valued answered 11/11, 2015 at 19:36 Comment(1)
what i am doing is just calling this inside a pre created div with 300px width and 40px height i want when the drop down shows it should get over the div and show. right now it shows but it gets hidden as the height of main div is 40px onlyValued
U
5

None of the above answers worked for me. I just had to set the dropdownParent property in my configuration.

dropdownParent: 'body'

https://github.com/selectize/selectize.js/blob/master/docs/usage.md

Note - I am using Angular 7.

Hope this helps someone!

Underexposure answered 6/12, 2019 at 15:59 Comment(1)
This should be the accepted answer and works perfect.Dripping
E
2

In selectize.css you can change the z-index for the dropdown. The following works on my site:

.selectize-dropdown {
  position: absolute;
  z-index: 10000; /* adjust as necessary */
  border: 1px solid #d0d0d0;
  background: #ffffff;
  margin: -1px 0 0 0;
  border-top: 0 none;  
}
Exempt answered 11/11, 2015 at 19:47 Comment(2)
Sorry but not working for me what i am doing is just calling this inside a pre created div with 300px width and 40px height i want when the drop down shows it should get over the div and show. right now it shows but it gets hidden as the height of main div is 40px onlyValued
This is useless because the z-index property is ignored when the position property has a value of 'absolute'.Consonant
S
2

Forget about the selectize.css classes. What works for me is:
Create another class with the following:

.myNewClass {
   position: absolute !important;
   z-index: 999;
}

And put this class inside your <select> tag.
After this you should realign your element, but the problem might be solved.

Sociability answered 2/3, 2016 at 18:44 Comment(0)
W
1

Bootstrap framework and it's working fine

.selectize-dropdown {
    z-index: 9999!important;
}
Words answered 16/7, 2019 at 7:44 Comment(0)
C
1

If you use bootstrap 3 or bootstrap 2 don't forget to load the css as well. You can find the css files here. Please load your css accordingly.

Consistency answered 20/3, 2020 at 12:22 Comment(0)
C
0

I am using UIKit 3.x and this works for me

.selectize-dropdown-content {
    z-index: 999;
    background: white;
    border: 1px solid #e5e5e5; // this is optional
}
Cyanosis answered 4/6, 2017 at 12:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.