In the following example is there a bootstrap way of truncating (with ellipsis in the end) multiline text of unknown length in div with id text2
so that the height of its parent column with id column2
matches the height of column1
? My workaround was to give position-absolute
class to the div of text2
and applying overflow:hidden
to column2
but this of course cuts the text rather than truncates it.
Another approach is to add an absolutely positioned element at the end of column2
and apply gradient background to make the text 'fade' away in the end but it is not applicable in my case since the color of background of the <body>
tag changes randomly as well.
The trick with -webkit-line-clamp
requires setting static height for the clamping to occur and to make it cross-browser compatible and since I cannot predict the length of the text - I cannot know the height. Plus it wouldn't matter since my responsive design changes font-size on every @media
query of Bootstrap's width threshold.
https://www.codeply.com/go/PNsIY4PWdG
<div class="container">
<div class="row">
<div id="column1" class="col-6">
<a href="https://placeholder.com"><img src="http://via.placeholder.com/600x350" class="img-fluid"></a>
</div>
<div id="column2" class="col-6">
<div id="text1">
<h5>text 1 (of unknown length) Lorem ipsum dolor sit amet , consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore </h5>
</div>
<div id="text2">
<p>text 2 (also of unknown length) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
</div>
</div>
</div>
</div>