I have string which I truncate to fit in the card but when there is white space in the text it fit perfectly but when white space is not present it just overflow Just like this
My code for truncate look like this
function truncateString(string, maxLength) {
console.log(`${string.length} and ${maxLength}`)
return string.substring(0, maxLength) + "...";
}
What can be the reason? What can be an alternative?
And when I use text-overflow in CSS it will not cover height just like this
My HTML code look
<div class="dateDiv">
<p class="infoTxt">${noteObj.date}</p>
</div>
<div class="titleDiv">
<p class="title">${truncateString(noteObj.title,15)}</p>
</div>
<div class="contentDiv">
<p class="regularTxt">${truncateString(noteObj.note,188)}</p>
</div>
<div class="authorDiv">
<p class="infoTxt">${noteObj.author}</p>
</div>
<i class="delBtn fas fa-trash-alt fa-lg"></i>
<div class="noteOverlay"></div>