2012-11-15 35 views
0

我是一个弹出式输入框(javascrip自动完成)的div。 div现在弹出在输入框后面,我怎么会出现ontop?将div悬停在输入框顶部使用css

截图问题:

enter image description here

CSS代码为:

body { 
     font-family: Helvetica; 
     font-size: 11px; 
     color: #000; 
    } 

    h3 { 
     margin: 0px; 
     padding: 0px; 
    } 

    .suggestionsBox { 
     position: absolute; 
     left: 30px; 
     margin: 10px 0px 0px 0px; 
     width: 200px; 
     background-color: #000; 
     -moz-border-radius: 7px; 
     -webkit-border-radius: 7px; 
     border: 2px solid #000; 
     color: #fff; 
    } 

    .suggestionList { 
     margin: 0px; 
     padding: 0px; 
    } 

    .suggestionList li { 

     margin: 0px 0px 3px 0px; 
     padding: 3px; 
     cursor: pointer; 
    } 

    .suggestionList li:hover { 
     background-color: #659CD8; 
    } 

HTML代码:

<div> 
    <input type="text" size="30" value="" id="inputString" onkeyup="lookup(this.value);" onblur="fill();" /> 
    </div> 

感谢一如既往的帮助,

+1

尝试加入'的z-index:9999;' – Andy

回答

4

使用z-index财产尝试在.suggestionsBox

.suggestionsBox { 
    position: absolute; 
    left: 30px; 
    margin: 10px 0px 0px 0px; 
    width: 200px; 
    background-color: #000; 
    -moz-border-radius: 7px; 
    -webkit-border-radius: 7px; 
    border: 2px solid #000; 
    color: #fff; 
    z-index: 999; <------ Here 
} 
+1

你也可能要使用一些简短的手,以尽量减少负载,以及降供应商前缀,因为大多数现代浏览器现在使用未加前缀的border-radius版本。 .suggestionsBox { position:absolute; left:30px; margin:10px 0 0; width:200px; background-color:#000; border-radius:7px; border:2px solid#000; color:#fff; z-index:999; <------这里 } –

1

设置z-index属性。

.suggestionsBox { 
    position: absolute; 
    left: 30px; 
    margin: 10px 0px 0px 0px; 
    width: 200px; 
    background-color: #000; 
    -moz-border-radius: 7px; 
    -webkit-border-radius: 7px; 
    border: 2px solid #000; 
    color: #fff; 

    z-index: 100; 
}