2013-07-29 46 views
0

我有2個div S和希望第一個定義div(被稱爲befront)是從那之後,定義的div前(這被稱爲beback)。把先前(第一defibed)DIV在默認位置下一個(第二)DIV的前

使用position: absolute;腐敗的設計,所以我只想使用z-index哪個不起作用。

我已經使用了下面的CSS,但沒有運氣:

#befront { 
    width:100%; height:20px; background:red; 
    /* I expect that the rex box be in front of the yellow box*/ 
    margin-bottom:-20px; 
    z-index: 1000; 
} 
#beback { 
    width:100%; height:20px; background:yellow;z-index:1; 
} 

jsfiddle is here

回答

1

你能不能再補充 「的位置是:相對的;」到你的「#前列」?

#befront { 
width:100%; height:20px; background:red; 
/* I expect that the rex box be in front of the yellow box*/ 
margin-bottom:-20px; 
z-index: 1000; 
position: relative; 
} 
#beback { 
width:100%; height:20px; background:yellow;z-index:1; 
} 

z-index要求您的元素被定位以正確工作。

看到here

0

嘗試讓#bebackz-index是負值。將其更改爲-1或更低。 並添加positon它的值爲absoluterelative

相關問題