I have a layout with a set of divs each containing three fields in different fonts displayed as:
Author
Title Date
thus structured something like:
<div>
<div class="author">author</div>
<div>
<span class="title">title</span>
<span class="date">date</span>
</div>
</div>
The blocks are fixed width but the fields are variable width. I want the author and title to be cut off when they are too long so I applied:
.author, .title {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
This works for the author, but the title gets cut off only when the date is already moved to the next line. I'd like the title to be cut of as soon as the date hits the right side like this:
+---------------------------------+
| This is a very very long auto...|
| This is a long ti... (yesterday)|
+---------------------------------+
Is this possible with css?
EDIT
Some clarification. I understand how I can give the title a maximum width as shown in various answers, but that is not what I need. The entire box has a fixed width, and ALL fields have variable width.
BUT the second line needs to be cut off at the first field (title) instead of the last field (date). Thus I'd like the max-width of the title to depend on the width of the date. Examples:
+---------------------------------+
| This is a very very long auto...|
| Short title (2 days ago) |
+---------------------------------+
+---------------------------------+
| Some author |
| Bit Longer tit.. (long time ago)|
+---------------------------------+
+---------------------------------+
| Another author |
| This is a long ti... (yesterday)|
+---------------------------------+
I don't see how this is possible with CSS even when I restrict it to cutting edge browsers or when I start hacking the HTML with ugly things like tables.
Yet, it seems like a cleanest way to display the data to the end user, so I'm hoping for someone who knows the magic trick...