I need to create a one-lined 3-column layout. The left and right columns should each display one word without truncation (they should expand and contract to fit the word). The center column should display a potentially lengthy string, truncated to fit between the two columns.
Here's a bit of HTML to convey the idea:
<div class="container">
<div class="left">Left</div>
<div class="center">Center center center center center center center</div>
<div class="right">Right</div>
</div>
And some corresponding CSS:
.container {
whitespace: nowrap;
}
.left {
display: inline-block;
}
.center {
display: inline-block;
overflow: hidden;
}
.right {
display: inline-block;
}
The next step is to somehow set the center element to automatically expand or contract to fill the space between the left and right elements.
Something like center.width = container.width - left.width - right.width
Any ideas? Thanks
EDIT: Solved with a few minor changes to ianhirschfeld's response.
HTML:
<div class="container">
<div class="left">Left</div>
<div class="right">RightRightRight</div>
<div class="center">Center center center center center center center</div>
</div>
CSS:
.container {
white-space: nowrap;
overflow: hidden;
}
.left {
float: left;
}
.center {
overflow: hidden;
}
.right {
float: right;
}