Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>can you write same function but to fit width and height of a div? I have a div with fixed width and height, where I need to put text from database. if text is too big for div, I want to cut it and ad ... at the end? Possible? Thank you</p> <p>EDIT: I found JS solution for my question:</p> <pre><code>&lt;p id="truncateMe"&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean consectetuer. Etiam venenatis. Sed ultricies, pede sit amet aliquet lobortis, nisi ante sagittis sapien, in rhoncus lectus mauris quis massa. Integer porttitor, mi sit amet viverra faucibus, urna libero viverra nibh, sed dictum nisi mi et diam. Nulla nunc eros, convallis sed, varius ac, commodo et, magna. Proin vel risus. Vestibulum eu urna. Maecenas lobortis, pede ac dictum pulvinar, nibh ante vestibulum tortor, eget fermentum urna ipsum ac neque. Nam urna nulla, mollis blandit, pretium id, tristique vitae, neque. Etiam id tellus. Sed pharetra enim non nisl.&lt;/p&gt; &lt;script type="text/javascript"&gt; var len = 100; var p = document.getElementById('truncateMe'); if (p) { var trunc = p.innerHTML; if (trunc.length &gt; len) { /* Truncate the content of the P, then go back to the end of the previous word to ensure that we don't truncate in the middle of a word */ trunc = trunc.substring(0, len); trunc = trunc.replace(/\w+$/, ''); /* Add an ellipses to the end and make it a link that expands the paragraph back to its original size */ trunc += '&lt;a href="#" ' + 'onclick="this.parentNode.innerHTML=' + 'unescape(\''+escape(p.innerHTML)+'\');return false;"&gt;' + '...&lt;\/a&gt;'; p.innerHTML = trunc; } } &lt;/script&gt; </code></pre> <p>For my purpose I removed link from ..., as I have another tab on my page that holds complete text.</p>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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