html - z-index 不适用于 <input>

标签 html css forms svg z-index

我有一个 <svg>我想包围一个 <input>文本框。我设置了 z-index<svg>高于包含 <div> , 和 z-index<input>文本框更高,但 <svg>仍在 <input> 之上文本框。

http://jsfiddle.net/6R2mf/1/

<form id="before-list" onsubmit="return false;">
    <label for="search" class="ui-hidden-accessible">Label:</label>
    <div class="ui-input-search ui-body-inherit ui-corner-all ui-shadow-inset ui-input-has-clear"><span class="ui-helper-hidden-accessible" aria-live="polite" role="status"></span>
        <input style="z-index: 10000;" autocomplete="off" class="ui-autocomplete-input" name="search" id="search" value="" placeholder="placeholder" data-type="search" type="text"><a href="#" class="ui-input-clear ui-btn ui-icon-delete ui-btn-icon-notext ui-corner-all ui-input-clear-hidden" title="Clear text">Clear text</a>
    </div>
</form>
<svg style="position: absolute; left: 0px; top: 0px; z-index: 1001;" xmlns="http://www.w3.org/2000/svg" width="396" version="1.1" height="78">
    <path d="M37.321735818577594,19.412056931773776C91.00900384635584,19.71827132609725,306.20767155776537,15.079895914223181,359.3368606653108,21.253021635495596C412.4692927191486,27.426524157459045,410.1732367732173,50.26181430495186,356.10649891451214,56.45301593533142C302.039761055807,62.64421756571098,86.9940586922537,64.75550694155167,34.93643351307978,58.40023141777294C-17.12119166609414,52.04495589399421,-10.036532153974994,24.179328007664637,43.760747839468635,18.32136279265903C97.55802783291226,12.463397577653424,305.393552534696,22.43059390522592,357.72011347374155,23.252440127739302" stroke="#000000" fill="none" style=""></path>
</svg>

如何让输入文本框位于 SVG 之上?

(使用 Firefox 24 和 jQuery Mobile 1.4.0)

最佳答案

http://jsfiddle.net/6R2mf/4/

我在form中添加了如下样式

<form style="position: relative; z-index: 9999;" id="before-list" onsubmit="return false;">

编辑

http://jsfiddle.net/6R2mf/8/

我只是添加了position:relative;回到你的新 fiddle ,它再次工作

z-index 需要它所在的元素有一个position:relative或固定,或绝对才能工作

关于html - z-index 不适用于 &lt;input&gt;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21081125/

相关文章:

javascript - 如何在 POST 之前操作表单文件输入

html - CSS 浏览器兼容性问题 - <hr/>

javascript - 禁用 OnClick 事件,直到首先触发另一个事件

html - CSS:如何删除奇怪的线条

CSS 理解与边框相关的边距

html - 防止主要内容通过导航栏可见

html - 将鼠标悬停在菜单列表上时展开整个 div 以及子菜单项

javascript - 将下拉列表或文本输入值保存在同一列中(使用 Laravel 5.5)

html - 带有粘性页脚的 2 列布局

ios - SwiftUI 表单无法使用 Spacer() 正确定位