
Originally Posted by
schyffe
Hi, I'd like to have a 3 divs aligned horizontally like this:
Code:
| <- div1 -> | |-div2-| |-div3-|
All 3 of them should together be 100% in width. div2 and div3 has a fixed size, and I'd like div1 to expand to make the total width 100%.
You can either float the second and third elements to the right, or you can absolutely-position them and use the right box offset property. The latter is probably the more practical option as I'd expect these would occur later in the document. In either case, add a right margin to the first element, the width of which spans the two right-most elements.
A skeleton example:
Code:
body {
margin: 0;
padding: 0;
}
.a, .b, .c {
border: 1px solid;
}
.a {
margin-right: 11em; /* 5em * 2 + 0.5em * 2 */
}
.b, .c {
position: absolute;
top: 0;
width: 5em;
}
.b {
right: 5.5em;
}
.c {
right: 0;
}
HTML Code:
<div class="a">1</div>
<div class="b">2</div>
<div class="c">3</div>
Do be sure to use better class names: 'content' not 'a', for example; 'navigation' not 'b', perhaps.
Mike
Bookmarks