2012-02-07 73 views
-2
 h1, p { position: absolute; left: -9999px; } 

    div {position: relative;} 

#wrapper { background: #bedfe4 url(../images/sun.png) no-repeat left -30px; border: 5px solid #402309;} 

#cloud-01 { background: url(../images/clouds-01.png) no-repeat left -100px; }               

#cloud-02 { background: url(../images/clouds-02.png) no-repeat left top; } 

#mountains-03 { background: url(../images/mountain-03.png) no-repeat left bottom; } 

#ground { background: url(../images/ground-05.png) no-repeat left bottom; } 

#full-robot { width: 271px; } 

#branding { 
background: url(../images/robot-head.png) no-repeat center top; 
width: 271px; 
height: 253px; 
z-index: 4; 
} 

#content { 
background: url(../images/robot-torso.png) no-repeat center top; 
width: 271px; 
height: 164px; 
z-index: 3; 
margin-top: -65px; 
} 

    #sec-content { 
background: url(../images/robot-hips.png) no-repeat center top; 
width: 271px; 
height: 124px; 
z-index: 2; 
margin-top: -90px; 
} 

    #footer { 
background: url('../images/robot-legs.png') no-repeat center top; 
width: 271px; 
height: 244px; 
z-index: 1; 
margin-top: -90px; 
} 

1)爲什麼h1 & p使用絕對位置與div相比?對CSS元素的基本理解

2)在h1的leftmargin left:-9999px爲什麼需要將負9999像素向左?是那個offscreen?

3)通常這些保證金數字是負數。經驗法則向下和向左都是負向的。向上和向右都是正面的?

+0

1.什麼使得這個編程相關? 2.您發佈的CSS文件沒有附帶的標記,希望我們知道爲什麼要這樣編碼? – Oded 2012-02-07 21:18:06

+0

你可以重述這些問題嗎? – user978122 2012-02-07 21:18:57

+0

我不知道我是否可以在這裏避免聽起來的意思,但這真的不是這種「問題」的地方。您爲特定頁面發佈了特定的CSS。這不是任何默認樣板,所以唯一可以回答的方法是如果您發佈了html,但這將是代碼審覈,並且應該在另一個特定於該需求的網站上。 SO是用於調試和幫助的,而不是這個。 – 2012-02-07 21:20:12

回答

1

用戶正在使用-9999px的絕對定位將元素移出屏幕。他們爲什麼選擇這樣做我不知道。

絕對定位將元素帶出頁面的流程。如果你使用親戚,你會有非常寬的滾動條。

負向頂部定位向上繪製元素。負向左定位畫出左側的元素。正數的情況正好相反。