Note that there are some explanatory texts on larger screens.

plurals
  1. POtable-layout:fixed use text-overflow:ellipse and a second text showing
    primarykey
    data
    text
    <p>I am quite new to css, and i was searching already for hours for a solution to this problem. I have a fixed layout table in a resizable container. i have a resizing column, that has 2 texts, the first should do a text-overflow:ellipse while the second should always show (if possible). The requirement is to not show all the text in a table cell if it doesnt fit, but display the last 5 letters. I figured ill put 2 spans in a td, and give a width to the second, but the width is ignored. When i tried to float the element (i can only float left, cause floating right will put the last 5 letters to the end on an long column with little text, which is not ok), left, but then the first div is not getting smaller so the text-overflow:ellipse is not applied.</p> <p>E.g i need when td is short:</p> <pre><code>|Hello budd...ight?| </code></pre> <p>and</p> <pre><code>|Hello buddy ho...ight?| </code></pre> <p>but when td is long:</p> <pre><code>|Hello buddy how is it going tonight? | </code></pre> <p>This seems to be a fairly common requirement, so how can i achieve it? I do not want any javascript, im quite sure it can be solved by css, and maybe some extra divs...</p> <p>my html:</p> <pre><code>&lt;table style="table-layout:fixed"&gt; &lt;colgroup&gt; &lt;col/&gt; &lt;col width="200px"/&gt; &lt;/colgroup&gt; &lt;tr&gt; &lt;td&gt; &lt;span class="first"&gt;Hello buddy how is it going ton&lt;/span&gt; &lt;span class="second"&gt;ight?&lt;/span&gt; &lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>my css:</p> <pre><code>table { width: 90%; margin: 10px; } tr { height: 100px; } td { width: 50%; border: 1px solid blue; padding: 5px; height: 100px; vertical-align: top; position: relative; while-space:nowrap; } span.first { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid red; } span.second { border: 1px solid green; } </code></pre> <p>Any ideas how to achieve this? Any help is very appreciated. Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload