2012-03-04 84 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

我建议你使用媒体查询来对待不同的屏幕分辨率正确