I am building a table that has truncated headers and content using the :after selector.
I want to be able to move the :after
content onto a new line only where the header text is truncated, is there a way of doing this only using CSS?
I am currently using jQuery and window.resize
listeners to implement a solution similar to the one found here: HTML - how can I show tooltip ONLY when ellipsis is activated but would prefer to be able to do it without the extra overhead of the jQuery and the listeners
An example of the HTML and CSS is:
<style>
table, th, td {
max-width: 75%;
table-layout: fixed;
border: 1px solid black;
}
th {
white-space: nowrap;
overflow-x: hidden;
text-overflow: ellipsis;
}
th:after {
content: ":";
}
</style>
</head>
<body>
<table width="600px">
<thead>
<tr>
<th width="5%">I'm a very long table header that is going to get truncated in the browser</th>
<th width="10%">small</th>
<th width="20%">medium</th>
<th width="65%">large</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>One</td>
<td>Java</td>
<td>01/01/2010</td>
</tr>
<tr>
<td>2</td>
<td>Two</td>
<td>C</td>
<td>01/02/2010</td>
</tr>
</tbody>
</table>
</body>
</html>