Hyper
Hyper

Reputation: 312

3 column layout with fixed left and right column. Right column flows into center column on smaller screens

HTML Setup

<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; 
}

The issue is that the center column needs to have a min-width, but the right column shouldn't move into the center column.

Upvotes: 5

Views: 3679

Answers (2)

toopay
toopay

Reputation: 1635

Try set width of center column as auto rather define its minimum width,

 #centerCol {
    margin-left: 310px;
    margin-right: 360px;
    height: 100%;
    width: auto;
}

Upvotes: 4

Gus
Gus

Reputation: 7349

Make #fixed-wrapper positioned relatively, so that the #leftCol and #rightCol are positioned absolutely with respect to it, rather than to the document body.

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

jsFiddle example

Upvotes: 0

Related Questions