How to select options overlapping an absolute positioned DIV?

这一生的挚爱 提交于 2019-12-03 00:22:26

No element will apply the z-index value without also having a position attribute (absolute, relative, fixed, etc).

Try adding position:relative to your select so that it inherits a z-index value.

See this screencast for a more in depth explanation.

As per the specifications (http://docs.webplatform.org/wiki/html/elements/option)

Except for background-color and color, style settings applied through the style object for the option element are ignored.

And hence the z-index property is ignored and the default behavior is to show the drop down above all elements on the document.

This works (using jquery - should be called on the mouseover event):

var $select = $("select").blur();
if ($.browser.webkit) {
  $select.hide();
  setTimeout(function() {
    $select.show()
  }, 5);
}

blur seems to suffice in IE7-9 and FF. Webkit doesn't respect this (bugs are filed against this), so the solution seems to be to hide and show the select box quickly.

Try:

form, select, options{ z-index:10;}

Perhaps the form tag is giving it the overlay. It should work as you have it, as IE does take into account z-index.

Regards, -D

Hiding Select through script is the current option available

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!