2010-11-02 157 views
2

考慮下面的HTML:兩個div左右浮動:頁面大小調整時,如何將它們保持在同一水平上?

<!DOCTYPE html> 
<html> 
<body> 
    <div id="container"> 
    <div id="left" style="float: left; background-color: #777; width: 500px;"> 
     Here is some content. Blah blah blah etc. 
     <div style="height: 50px;">Some more content</div> 
     And finally some more. 
    </div> 
    <div id="right" style="float: right; background-color: #aaa; width: 500px;"> 
     Here is some content. Blah blah blah etc. 
     <div style="height: 50px;">Some more content</div> 
     And finally some more. 
    </div> 
    <div style="float: clear;"></div> 
    </div> 
</body> 
</html> 

我能做些什麼來div#container或其他標記,以防止div#rightdiv#left下移動時我調整瀏覽器窗口使得這些窗口寬度越小則1000px

回答

7

設置一個min-width您的容器:

#container { 
    min-width: 1000px; 
} 
2

#container DIV a min-width: 1000px財產,這樣的父母將永遠足夠寬,以保持兩個孩子並排。

-2

http://www.w3schools.com/css/default.asp我學會了所有我在這裏的CSS,有上定位一節,是非常有幫助的,我建議閱讀它,現在你的工作,以及未來的項目。

嘗試:

#container { 
    position: relative; 
} 
+0

沒有這樣做。你應該改變你的答案或刪除代碼。雖然我欣賞這個鏈接。我會檢查出來的。 – DJTripleThreat 2010-11-02 23:41:14

0

div容器不是在你的代碼關閉。請檢查一次,並應用min-width:1000px;

相關問題