Reputation: 19896
I would like to do this simple layout:
width = 200px
width = 400px
This is the sample I have (but with col3's width as 100px). So the question is how to fix css of col3
to make it fluid but still reserve position:fixed
?
My last alternative is to use jQuery. But I don't want to touch it unless really necessary for layout.
Thanks.
Upvotes: 4
Views: 784
Reputation: 272146
For absolute/fixed positioned elements, width is a function of left and right. So, set the left: 600px; right: 0;
on the third column and browser will determine the width. That is it. Here is the revised CSS, with few changes for consistency:
.col1 {
position: fixed;
top: 0;
bottom: 0;
left: 0;
width: 200px;
background: red;
}
.col2 {
margin-left: 200px;
width: 400px;
height: 100%;
background: green;
}
.col3 {
position: fixed;
top: 0;
bottom: 0;
left: 600px;
right: 0;
background: blue;
}
Upvotes: 2
Reputation: 171669
Can do it using float:left
or absolute position for the left and middle columns and set margin-left
equal to their combined widths.
.col1 {
background: red;
float:left;
width: 200px;
height:100%
}
.col2 {
background: green;
float:left;
width: 400px;
height:100%
}
.col3 {
background: blue;
margin-left:600px;
}
DEMO: http://jsfiddle.net/Endt7/3/
Upvotes: 0