अधिकांश समाधान यहाँ स्थैतिक चौड़ाई का उपयोग करते हैं। लेकिन यह कभी-कभी कुछ कारणों से गलत हो सकता है।
उदाहरण: मेरे पास कई स्तंभों वाली तालिका थी। उनमें से अधिकांश संकीर्ण (स्थिर चौड़ाई) हैं। लेकिन मुख्य स्तंभ जितना संभव हो उतना चौड़ा होना चाहिए (स्क्रीन आकार पर निर्भर करता है)।
HTML:
<table style="width: 100%">
<tr>
<td style="width: 60px;">narrow</td>
<td>
<span class="cutwrap" data-cutwrap="dynamic column can have really long text which can be wrapped on two rows, but we just need not wrapped texts using as much space as possible">
dynamic column can have really long text which can be wrapped on two rows
but we just need not wrapped texts using as much space as possible
</span>
</td>
</tr>
</table>
सीएसएस:
.cutwrap {
position: relative;
overflow: hidden;
display: block;
width: 100%;
height: 18px;
white-space: normal;
color: transparent !important;
}
.cutwrap::selection {
color: transparent !important;
}
.cutwrap:before {
content: attr(data-cutwrap);
position: absolute;
left: 0;
right: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: #333;
}
/* different styles for links */
a.cutwrap:before {
text-decoration: underline;
color: #05c;
}