0

I would obtain a 3 column footer with fixed width left and right column and the central fill the remaining space:

.
.
.
|[LEFT]<------central------>[RIGHT]|

Now I'm using this code, but the central column has fixed width :(

.left  
{  
  float:left;  
  width: 100px;  
}  
.central  
{  
  float:left;  
  width: {xxx}px  
}  
.right  
{  
  float:right;  
  width: 100px;  
}  
willygroup
  • 143
  • 1
  • 10

3 Answers3

1

Try to do this:

CSS:

.left  
{  
  float:left;  
  width: 100px;
}  
.central  
{
  width: 100%;
  margin: 0 auto;   
}  
.right  
{  
  float: right;    
  width: 100px;
}

and your HTML must be in this order (left, right and central) to work:

<div class="left">test</div>    
<div class="right">test</div>
<div class="central">test</div>

I wrote "test" just to see the results. =)

Hugs, Vin.

Vinicius Lima
  • 534
  • 7
  • 20
0

http://jsfiddle.net/qtzKk/

Use absolute positioning and the left and right attributes if you want a fixed width for your left and right hand divs.

You can wrap it with a relative positioned div so it's not overlapped by your site content.

Toon Casteele
  • 2,479
  • 15
  • 25
  • Absolute positioning does not play nicely with content where the size is unknown. – cimmanon Apr 30 '13 at 13:35
  • It does in his case if he wants fixed width on the two outer divs. And as I said before. He can size the wrapper around the 3 divs any way he likes. – Toon Casteele Apr 30 '13 at 13:37
  • Only the width is known here, not the height. What happens when the contents are taller than the viewport? It gets cut off. – cimmanon Apr 30 '13 at 13:38
  • Again... It doesn't if you wrap it with a relative positioned div with whatever height you like. You can even scroll them if you like... You're completely free to modify to your choosing. – Toon Casteele Apr 30 '13 at 13:40
0

If you modify your source order, you can continue using floats but only for the left and right elements:

http://tinker.io/99f07/2

.left  
{  
  float:left;  
  width: 100px;  
}  
.central  
{  
    margin-left: 100px;
    margin-right: 100px;
}  
.right  
{  
  float:right;  
  width: 100px;  
}  

<div class="left">
    Left
</div>

<div class="right">
    Right
</div>

<div class="central">
    Lorem ipsum dolor...
</div>

Otherwise, changing the display type of all 3 sibling elements to table-cell will do the job (as an added benefit, the elements are now equal height):

http://tinker.io/99f07/1

/* optional
body {
    display: table;
    width: 100%;
}*/

.left  
{  
  display: table-cell;  
  width: 100px;  
}  
.central  
{  
  display: table-cell;  
}  
.right  
{  
  display: table-cell;  
  width: 100px;  
}
cimmanon
  • 67,211
  • 17
  • 165
  • 171