2010-05-19 62 views
1

我需要一個2列接口來拉伸100%的頁面高度。(高度100%)加上(2列css)

PS:如果列太長,應該出現滾動條。這個問題解決後,我會嘗試添加一個粘性頁腳到界面。

PPS:請,沒有解決方案使用「假」的背景圖像

我真的很努力地用自己找到答案...... 感謝,如果您有任何想法

這裏的代碼

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB"> 
<head> 
    <title>2 Column CSS Demo - Equal Height Columns with Cross-Browser CSS</title> 

    <style media="screen" type="text/css"> 
/* <!-- */ 
*{ 
    margin:0; 
    padding:0; 
} 

    html { 
    background-color: #ccc; 
     height: 100%; 
    } 
    body { 
    background-color: white; 
    width: 600px; 
    margin: 0 auto; 
height:100%; 
    position: relative; 
    border-left: 1px solid #888; 
    border-right: 2px solid black; 
    } 

#footer { 
    clear:both; 
    width:100%; 
    height:0px;font-size:0px; 
} 


#container2 { 


    clear:left; 
    float:left; 
    width:600px; 
     overflow:hidden; 
    background:#ffa7a7; 
} 



#container1 { 

    float:left; 
    width:600px; 
    position:relative; 
    right:200px; 
    background:#fff689; 
} 
#col1 { 
    float:left; 
    width:400px; 
    position:relative; 
    left:200px; 
     overflow:hidden; 
} 
#col2 { 
    float:left; 
    width:200px; 
    position:relative; 
    left:200px; 
     overflow:hidden; 
} 
/* --> */ 
    </style> 
</head> 
<body> 

<div id="container2"> 
    <div id="container1"> 
     <div id="col1"> 
      aaaa a a a a a a a a a aa aa a a a a a a a a aa aa a a a a a a a a aa aa a a a a a a a aa a a a a aa aa a a a a a a a a aa aa a a a a a a a a aa aa a a a a aa a a a a aa aa a 
     </div> 
     <div id="col2"> 

      fghdfghsfgddn fghdfghsfgddn fghdfghsfgddn fghdfghsfgddn fghdfghsfgddn fghdfghsfgddn fghdfghsfgddn v 
     </div> 
    </div> 
</div> 
<div id="footer"> 
    &nbsp; 
</div> 
</body> 

回答

1

取決於你的目標瀏覽器,你可以使用所有的最簡單的方法:CSS3 Columns

.columns { 
    -moz-column-count: 2; 
    -webkit-column-count: 2; 
} 
+0

謝謝。但我也需要IE和Opera ... – user345161 2010-05-19 14:36:44

2

它不應該那麼辛苦。請看看這段代碼。

<html> 
<head> 
<title>Columns</title> 
</head> 
<body> 
<style type="text/css"> 
.wrapper { 
    width:1200px; 
    margin:0 auto; 
} 
.col1 { 
    width:600px; 
    height:100%; 
    float:left; 
    background:#f00; 
} 
.col2 { 
    width:600px; 
    height:100%; 
    float:left; 
    background:#00f; 
} 
</style> 
<div class="wrapper"> 
    <div class="col1"> 
     Column 1 
    </div> 
    <div class="col2"> 
     Column 2 
    </div> 
</div> 
</body> 
</html> 

.wrapper只是居中2列。

+0

你是個天才!此代碼在qiuirks模式下工作!然而,我很努力使這項工作嚴格/過渡文檔類型。那麼,偉大的職位人。你是一個非常幸運的初學者!!!!! – user345161 2010-05-19 18:16:50

+0

來標記代碼,每行縮進4個空格 - 編輯區域右側有一個幫助欄。 – nickf 2010-05-20 01:24:45

+0

還有一個很好的答案,你們都很棒 – user345161 2010-05-20 05:08:22

1

您是否嘗試在容器上繼承身體的高度?

IE高度:繼承;

+0

******************************************** 太棒了,有幫助我爲<!doctype嚴格>! ******************************************** – user345161 2010-05-20 05:07:47