I have a sentence that contains job title and location, and I have a limitation of two lines for writing the whole sentence.
The maximum length of the location is 30 characters, but the maximum length of the job title is unknown.
In order to achieve it, I need to make the job title more shorter (with dot dot dot).
These examples work fine:
<div id="container">
<span>Find more</span>
<span id="job" class="ellipsis">Sales Manager</span>
<span>jobs in </span>
<span id="location">san francisco, california, usa</span>
</div>
<div id="container">
<span>Find more</span>
<span id="job" class="ellipsis">Sales Manager</span>
<span>jobs in </span>
<span id="location">san francisco, ca</span>
</div>
But these examples don't work:
<div id="container">
<span>Find more</span>
<span id="job" class="ellipsis">Sales Manager and driver</span>
<span>jobs in </span>
<span id="location">san francisco, ca</span>
</div>
The job should be replaced with "Sales Manager and ..."
By this way, the sentence will be exactly two rows.
<div id="container">
<span>Find more</span>
<span id="job" class="ellipsis">Sales Manager and driver</span>
<span>jobs in </span>
<span id="location">san francisco, california, usa</span>
</div>
The job should be replaced with "Sales Manager..."
By this way, the sentence will be exactly two rows.
This is my css:
#container {
width:208px;
boder: 1px solid black;
height: 2em; /* two lines limit */
line-height: 1em; /* two lines limit */
overflow: hidden; /* two lines limit */
}
.ellipsis { /* dot dot dot */
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
And these are my snippest (I have created the same snippest in two platforms):
1) http://jsfiddle.net/Ht6Ym/3734/
#container {
width:208px;
boder: 1px solid black;
height: 2em; /* two lines limit */
line-height: 1em; /* two lines limit */
overflow: hidden; /* two lines limit */
}
.ellipsis { /* dot dot dot */
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
<div style="color:red;">It works:</div>
<div id="container">
<span>Find more</span>
<span id="job" class="ellipsis">Sales Manager</span>
<span>jobs in </span>
<span id="location">san francisco, california, usa</span>
</div>
<br>
<div id="container">
<span>Find more</span>
<span id="job" class="ellipsis">Sales Manager</span>
<span>jobs in </span>
<span id="location">san francisco, ca</span>
</div>
<div>--------------------------</div>
<div style="color:red;">It doesn't work:</div>
<div id="container">
<span>Find more</span>
<span id="job" class="ellipsis">Sales Manager and driver</span>
<span>jobs in </span>
<span id="location">san francisco, california, usa</span>
</div>
<br>
<div id="container">
<span>Find more</span>
<span id="job" class="ellipsis">Sales Manager and driver</span>
<span>jobs in </span>
<span id="location">san francisco, ca</span>
</div>
Any help appreciated!