2011-09-29 33 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

啊,這個微不足道的錯誤......應該已經知道了。好吧。非常感謝,我能夠接受答案。這工作。 –

相關問題