0

我正在尝试制作以首页为中心的四列。我希望它看起来像这个例子:
http ://www.clutterpad.com/

我的代码如下所示:

#bottom-container {width:100%;height:250px;position:relative;}
#bottom-mid {background-color:white;}
#bottom-left, #bottom-mid, #bottom-right {height:250px;}
#bottom-left, #bottom-right {width:50%;float:left;}

#bottom-left {background-color:white;position:absolute;top:0px;left:0px;}
#bottom-right {background-color:white;position:absolute;top:0px;left:50%;}

#bottom-mid {position:relative;margin:0px auto; width:1000px;z-index:2;}
#column-container {width:100%; margin:20px auto;}
.column {width:200px;float:left;font-size:10pt;font-family:Arial;margin:20px 10px;}

但这行不通。我应该如何编写代码使其看起来像我之前提到的示例?

4

2 回答 2

3

如果您可以包含 HTML,那就太好了,但我会这样处理问题:

<div id="fourcolumns">
    <div>Column</div>
    <div>Column</div>
    <div>Column</div>
    <div>Column</div>
</div>

CSS:

#fourcolumns {
    width: 100%;
    overflow: hidden;
}

#fourcolumns div {
    width: 25%;
    float: left;
}

如果您在列之间添加边距,您将成为 IE6 双边距浮动错误的受害者,您可以通过包括#fourcolumns div { display: inline; }

于 2010-05-13T11:58:32.433 回答
-1
<div id="fourcolumns"> 
    <div>Column</div> 
    <div>Column</div> 
    <div>Column</div> 
    <div>Column</div> 
</div> 

CSS:

#fourcolumns { 
    margin: 0 auto;
    width: 50%; 
    overflow: hidden; 
} 

#fourcolumns div { 
    width: 25%; 
    float: left; 
} 
于 2010-05-13T12:50:39.423 回答