2013-08-24 33 views
1

我正在爲我的網站製作標題。我在標題中有一個搜索框,搜索結果應該顯示在它的正下方。我調整了搜索結果div的位置,但是當我改變屏幕的分辨率時div移開了。 我在HTML中下面的代碼:CSS:改變changin分辨率的位置

<div id = "header"> 
    <div id = "header_wrapper"> 
     <div id = "search_results"> 

     </div> 
    </div> 
</div> 

並在CSS:

*{ 
    margin:0px; 
} 
#header{ 
    width:100%; 
    border:1px solid #f1f1f1; 
    height:100px; 
} 
#header_wrapper{ 
    width:1000px; 
    margin:auto; 
    border:1px solid #f1f1f1; 
    height:100px; 
} 
#search_results{ 
    position:absolute; 
    left:30%; 
    height:100px; 
    width:500px; 
    border:1px solid #f1f1f1; 
    top:100px; 
} 

我怎樣才能調整DIV,使其不改變其相對位置與它的父DIV上改變屏幕resolution.Please幫助

+0

你能爲此[jsfiddle](http://jsfiddle.net/)。 –

回答

1

只需用你的CSS替換,我希望它會工作,你想要的。

*{ 
    margin:0px; 
} 
#header{ 
    width:100%; 
    height:100px; 
} 
#header_wrapper{ 
    width:1000px; 
    margin:auto; 
    border:1px solid #000; 
    height:100px; 
    position:relative; 
} 
#search_results{ 
    position:absolute; 
    left:25%; 
    height:100px; 
    width:500px; 
    border:1px solid #000; 
    top:80px; 
} 
+0

謝謝你的工作.. – user1763032