jQuery-UI's autocomplete not display well, z-index issue

前端 未结 12 1058
情深已故
情深已故 2021-01-31 12:54

I\'m currently implementing jQuery UI\'s autocomplete in my clients webshop. The problem is: the element the autocomplete resides in, has a higher z-index then the z-index of th

相关标签:
12条回答
  • 2021-01-31 13:34

    While searching I found this topic (http://forum.jquery.com/topic/alternating-style-on-autocomplete). Apparently the only way to change the style of the autocomplete box is by doing it through javascript:

        open: function(){
            $(this).autocomplete('widget').css('z-index', 100);
            return false;
        },
    
    0 讨论(0)
  • 2021-01-31 13:35

    If you are able to enforce a higher z-index upon the autocomplete text input then this is the solution to your problem.

    jQuery UI Autocomplete options list calculates its z-index value by taking the z-index of the text input it's being attached to and adds 1 to that value.

    So you can give a z-index of 999 to the text input the autocomplete will have a z-index value of 1000

    Taken from http://bugs.jqueryui.com/ticket/5489

    <input type="text" class="autocomplete" style="z-index:999;" name="foo">
    
    0 讨论(0)
  • 2021-01-31 13:37

    Try this, you can manipulate the z-index on runtime or initializing

    $('#autocomplete').autocomplete({
        open: function(){
            setTimeout(function () {
                $('.ui-autocomplete').css('z-index', 99999999999999);
            }, 0);
        }
    });
    
    0 讨论(0)
  • 2021-01-31 13:40

    add the following

    .ui-autocomplete
    {
        z-index:100 !important;
    }
    

    in jquery-custom-ui.css file (or the minified one if you are using it).

    0 讨论(0)
  • 2021-01-31 13:41

    In the CSS of jQuery UI:

    .ui-front { z-index: 9999; }
    
    0 讨论(0)
  • 2021-01-31 13:41

    Give it a try anyway in your css (before script loading), not in firebug:

    .ui-selectmenu-menu {
        z-index:100;
    }
    

    In my case this works and creates z-indexes like : 100x (for example 1002)

    0 讨论(0)
提交回复
热议问题