2012-01-15 23 views
11

jQueryを使用するとdiv oneがdivより上にあるかどうかを調べることができますtwo?そうでないと、どのz-indexが高いのですが、divは他のdivよりも視覚的に見えます。要素が別の要素の上にある場合?

<style type='text/css'> 
    #one { 
    position:absolute; top:0; left:0; width:100px; height:100px; background-color:red; z-index:2; 
    } 
    #two { 
    position:absolute; top:0; left:0; width:100px; height:100px; background-color:green; z-index:1; 
    } 
    </style>  
    <div id='one'></div> 
     <div id='two'></div> 
+0

これが重複することがありますhttp://stackoverflow.com/questions/8628368/how-do-i-implement-collision-detection-between-a-set-of-div-elements –

答えて

13

あなたは、ドキュメントの端からスペースを取得するためにoffset方法(here)を使用することができます。要素の幅と高さを追加し、その数を引く。

Offset and width for div's

関連する問題