2014-01-29 46 views
-1

我遇到了一個問題,我是相當新的CSS,但我如何讓一個div超過其他?這是我的代碼:divs在另一個位置,CSS

#left_box 
{ 
margin-top: 0px; 
min-width: 10%; 
max-width: 10%; 
height: 800px; 
background: #C90; 
border: thin 5px #33CCFF; 
position: absolute; 
z-index:1; 
left: 16px; 
top: 1px; 
float:none; 
} 

#bar_outside 
{ 

margin-top:75px; 
min-width:10px; 
max-width:2000px; 
height:55px; 
background:#ff69b4; 
border:#ff69b4: 5px; 
position:static; 
z-index:2; 

}

I want the pink box to go over the orange box

感謝您的幫助!

+0

更改'position:static;'到'position:relative;'z-index不能應用靜態定位元素 –

+0

爲了使'z-index'工作,您必須使用'position:relative/absolute/fixed'。 – Vucko

+4

http://jsfiddle.net/6RLqz/那樣? – CRABOLO

回答

0

你不需要位置:絕對。左浮動,並定義寬度

3

如果你想一個div來放在另一個的上面,你可以在你#bar_outside改變position: staticposition:relative爲z-index屬性只適用於相對的,絕對的或固定的。 See the fiddle

如果您想將div放置在另一邊,請在您的CSS類中使用相應的CSS屬性floatSee the fiddle

相關問題