I'm using bootstrap 3 tables, when i put large text in the table it gets wrapped on several lines, but i want it to be truncated with three dots at the end in a responsive way without messing up the layout of the table (i found some solutions but with unpleasant effects).
Is that possible ? how ?
PS: any solution is welcome, but i would like it to be just HTML/CSS if it's possible.
This question is related to
html
css
twitter-bootstrap-3
responsive-design
I'm using bootstrap.
I used css parameters.
.table {
table-layout:fixed;
}
.table td {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
and bootstrap grid system parameters, like this.
<th class="col-sm-2">Name</th>
<td class="col-sm-2">hoge</td>
This is what I achieved, but had to set width, and it cannot be percentual.
.trunc{_x000D_
width:250px; _x000D_
white-space: nowrap; _x000D_
overflow: hidden; _x000D_
text-overflow: ellipsis;_x000D_
}_x000D_
table tr td {_x000D_
padding: 5px_x000D_
}_x000D_
table tr td {_x000D_
background: salmon_x000D_
}_x000D_
table tr td:first-child {_x000D_
background: lightsalmon_x000D_
}
_x000D_
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>_x000D_
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>_x000D_
<table>_x000D_
_x000D_
<tr>_x000D_
<td>Quisque dignissim ante in tincidunt gravida. Maecenas lectus turpis</td>_x000D_
<td>_x000D_
<div class="trunc">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum._x000D_
</div>_x000D_
</td>_x000D_
</tr>_x000D_
</table>
_x000D_
or this: http://collaboradev.com/2015/03/28/responsive-css-truncate-and-ellipsis/
You need to use table-layout:fixed
in order for CSS ellipsis to work on the table cells.
.table {
table-layout:fixed;
}
.table td {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
Source: Stackoverflow.com