2011-09-29 212 views
0

我在页面上有几个控件。其中一个是按钮,另一个是宽度为100%的div。该按钮的位置:绝对。Div正在铺设绝对定位元素的顶部。如何把元素放在div上面?

我的按钮CSS - 只是玩了现在:

.toggleButton 
{ 
    z-index: 99999999px; 
    position: absolute; 
    margin-top: 2px; 
    right: 130px; 
} 

DIV的是自动生成的,但这里是它的计算方式:

background-color: transparent; 
clear: both; 
color: dimGray; 
display: block; 
font-family: 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; 
font-size: 11px; 
height: 26px; 
margin-bottom: 0px; 
margin-left: 0px; 
margin-right: 0px; 
margin-top: 0px; 
min-height: 0px; 
overflow-x: hidden; 
overflow-y: hidden; 
padding-bottom: 0px; 
padding-left: 0px; 
padding-right: 0px; 
padding-top: 0px; 
position: relative; 
width: 1026px; 

我不知道如何把div上的按钮。在当前状态下,按钮无法在所有位置点击。我不想限制div的宽度,只需将按钮放在它上面。

enter image description here

回答

1

z索引不在像素单元。所以的div你的z-index设置为1,并且按钮的z-index设置为20

.toggleButton 
{ 
    z-index: 20; 
    position: absolute; 
    margin-top: 2px; 
    right: 130px; 
} 

我需要这样的参考,但我敢肯定的z-index在100所以封顶像9999999这样的时髦巨大数字只是被认为是100.

+0

我相信它取决于浏览器,但总体上限更接近10k我相信。有关更多信息,请参阅http://stackoverflow.com/questions/491052/mininum-and-maximum-value-of-z-index/491105#491105。 –

+0

根据[规范](http://www.w3.org/TR/CSS2/visuren.html#propdef-z-index),没有定义最大值。我过去使用过100多个,没有问题。 –

+0

啊,这个微不足道的错误......应该已经知道了。好吧。非常感谢,我能够接受答案。这工作。 –

相关问题