5

HTML 设置

<div id="fixed-wrapper">
<div id="header">
        <h1>Site Name</h1>
</div>
<div id="leftCol"></div>
<div id="centerCol"></div>
<div id="rightCol"></div>

CSS:

#fixed-wrapper{
    min-width: 1264px;
}
#header{
    width: 100%;
    height: 75px;   
    text-align: center;
}
#header h1 
{
    line-height: 75px;   
}
 #centerCol {
    margin-left: 310px;
    margin-right: 360px;
    height: 100%;
    min-width: 604px;
}
#rightCol {
    width: 285px;
    height: auto;
    position: absolute;
    top: 75px;
    right: 0;
    margin-right: 75px;
}
#leftCol {
    width: 235px;
    height: auto;
    position: absolute;
    top: 75px;
    left: 0;
    margin-left: 75px; 
}

问题是中心列需要有一个最小宽度,但右列不应该移动到中心列。

4

2 回答 2

4

尝试将中心列的宽度设置为自动而不是定义其最小宽度,

 #centerCol {
    margin-left: 310px;
    margin-right: 360px;
    height: 100%;
    width: auto;
}
于 2011-07-27T17:53:40.957 回答
0

使#fixed-wrapper 相对定位,以便#leftCol 和#rightCol 相对于它绝对定位,而不是相对于文档正文。

#fixed-wrapper{
    min-width: 1264px;
    position: relative;
}

jsFiddle 示例

于 2011-07-27T17:51:35.647 回答