2012-03-04 58 views
0

我怎樣才能讓我的背景行事position: absolute;作爲我的幾個div元素的頂部?我試圖在不同的屏幕分辨率下使我的div元素和背景保持同步。以下是我迄今爲止實施的小代碼。背景圖像呆在一起與divs

<!doctype html><head> 

<title>Coming Soon! </title></head> 



<style> 

* { 

padding: 0px; 
margin: 0px; 
} 

#searchfold { 
    background: url("../imgs/search_box.png") no-repeat scroll 0 0 transparent; 
    height: 335px; 
    margin-left: 173px; 
    margin-top: 135px; 
    width: 890px; 
    position: absolute; 

} 


#bottomfoldbox { 
    background: url("../imgs/bottom_foldbox.png") no-repeat scroll 0 0 transparent; 
    height: 335px; 
    margin-left: 173px; 
    margin-top: 750px; 
    width: 890px; 
    position: absolute; 
} 

#searchfield { 
    float: right; 
    height: 50px; 
    margin-right: 178px; 
    margin-top: 250px; 
    width: 296px; 
} 


</style> 


</head> 

<body style="background-image: url('http://mysite.com/wp/wp-content/uploads/2012/02/mysite_Homepage.gif'); background-repeat: no-repeat; background-position: center; height: 1055px; position: relative;"> 


<div id="searchfold"> 

<div id="searchfield"> 
<form name="input" action="html_form_action.asp" method="get"> 
<input type="text" name="user" style="height:40px; width:200px;"/> 
<INPUT type="image" name="search" src="../imgs/search_btn.png" border="0" style=" float: right; 
    margin-right: -130px; 
    margin-top: -19px;}"></form> 
</div> 

</div> 



</div> 


<div id="bottomfoldbox"> 


</div> 
</div> 

</body> 


</html> 
+1

在哪裏開''標籤? *(注意:'DOCTYPE's不算。)* – 2012-03-04 00:55:05

+0

所以,<!doctype html> ?? – 2012-03-04 00:58:17

+0

仍然沒有這樣的運氣,謝謝你的迴應! – 2012-03-04 01:26:56

回答

0

我建議你使用媒體查詢來對待不同的屏幕分辨率正確