Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

z-index not working for <input>

I've got an <svg> that I want to surround an <input> text box. I've set the z-index of the <svg> to be higher than the containing <div>, and the z-index of the <input> text box to be even higher, yet the <svg> is still on top of the <input> text box.

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>

How can I get the input text box to be on top of the SVG?

(Using Firefox 24 & jQuery Mobile 1.4.0)

like image 579
Jayen Avatar asked Jan 12 '14 22:01

Jayen


1 Answers

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

I added the following style to form

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

EDIT

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

I just added the position: relative; back in to your new fiddle, and it works again

z-index needs the element it's on to have a position: relative or fixed, or absolute for it to work

like image 101
CRABOLO Avatar answered Sep 27 '22 21:09

CRABOLO