jQuery UI API - Stacking Elements
Widgets that stack or move in front of other elements often face challenges when placed in real-world pages. Conflicts on the page are usually avoided by simply changing the stacked element's z-index or parent element. However, jQuery UI needs a general solution that does not require manually changing z-index values. This is accomplished through the ui-front class, usually accompanied by the appendTo option.
ui-front class
ui-front class on the stacking component. The class is very basic. It simply sets a static z-index value on the element. However, the presence of the class indicates where the stacked element should be appended. This allows us to take advantage of nested stacking contexts and generate a default DOM position that works in most cases.
Note: When using ui-front , you must set position is relative、 absolute or fixed, so that the z-index。
stacking technique
Any widget that appends stacked elements to the page must use the ui-front class and, in most cases, should have an appendTo option. Stacked elements should follow these rules:
- If a value is set for the
appendTooption, append the stacked element to the specified element. - If both the
appendToIf the option is set tonull(the default), the widget should traverse the DOM starting from the associated element. For example, when an autocomplete menu is appended to the DOM, traversal starts from the associated input element. - If an element with the
ui-frontclass is found, append to that element. - If no element with the
ui-frontclass is found, append to the body.
- The stacked element's
positionmust be set torelative、absoluteorfixed, so that theui-frontfrom the class take effectz-index. Using .position() will automatically setposition。