{"id":39,"date":"2018-04-18T11:01:28","date_gmt":"2018-04-18T09:01:28","guid":{"rendered":"http:\/\/www.wabbi.fr\/?p=39"},"modified":"2018-04-18T11:01:28","modified_gmt":"2018-04-18T09:01:28","slug":"multi-line-block-of-text-with-ellipsis","status":"publish","type":"post","link":"https:\/\/www.wabbi.net\/index.php\/2018\/04\/18\/multi-line-block-of-text-with-ellipsis\/","title":{"rendered":"Multi-line block of text with ellipsis"},"content":{"rendered":"<p>Usually, a block\u00a0of text in an HTML page may have the ellipsis (&#8230;) at its end to indicate that it has been cut-off. But, this works for the first line only of the text.<\/p>\n<p>Suppose that you have a &lt;div&gt; with a height that might show multiple lines of text, and you want to add the ellipsis at the last line. This is tricky but possible. I found a lot of solutions on the net, but this one is my preferred\u00a0as it is pure CSS. Juste give the following CSS class &#8220;block-with-text&#8221; to the &lt;div&gt; or &lt;p&gt; you want.<\/p>\n<p>\/* styles for &#8216;&#8230;&#8217; *\/<br \/>\n.<em>block-with-text<\/em> {<br \/>\n\/* hide text if it more than N lines *\/<br \/>\noverflow: hidden;<br \/>\n\/* for set &#8216;&#8230;&#8217; in absolute position *\/<br \/>\nposition: relative;<br \/>\n\/* use this value to count block height *\/<br \/>\nline-height: 1.2em;<br \/>\n\/* max-height = line-height (1.2) * lines max number (3) *\/<br \/>\nmax-height: 3.6em;<br \/>\n\/* fix problem when last visible word doesn&#8217;t adjoin right side *\/<br \/>\ntext-align: justify;<br \/>\nmargin-right: -1em;<br \/>\npadding-right: 1em;<br \/>\n}<\/p>\n<p>.<em>block-with-text:before<\/em> {<br \/>\n\/* points in the end *\/<br \/>\ncontent: &#8216;&#8230;&#8217;;<br \/>\n\/* absolute position *\/<br \/>\nposition: absolute;<br \/>\n\/* set position to right bottom corner of block *\/<br \/>\nright: 0;<br \/>\nbottom: 0;<br \/>\n}<\/p>\n<p>.<em>block-with-text:after<\/em> {<br \/>\n\/* points in the end *\/<br \/>\ncontent: &#8221;;<br \/>\n\/* absolute position *\/<br \/>\nposition: absolute;<br \/>\n\/* set position to right bottom corner of text *\/<br \/>\nright: 0;<br \/>\nwidth: 1em;<br \/>\n\/* set width and height *\/<br \/>\nheight: 1em;<br \/>\nmargin-top: 0.2em;<br \/>\nbackground: white;<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Usually, a block\u00a0of text in an HTML page may have the ellipsis (&#8230;) at its end to indicate that it has been cut-off. But, this works for the first line only of the text. Suppose that you have a &lt;div&gt; with a height that might show multiple lines of text, and you want to add &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.wabbi.net\/index.php\/2018\/04\/18\/multi-line-block-of-text-with-ellipsis\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Multi-line block of text with ellipsis&#8221;<\/span><\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[8,10,7,9],"class_list":["post-39","post","type-post","status-publish","format-standard","hentry","category-css-html","tag-css","tag-ellipsis","tag-html","tag-multi-line-text"],"_links":{"self":[{"href":"https:\/\/www.wabbi.net\/index.php\/wp-json\/wp\/v2\/posts\/39","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wabbi.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wabbi.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wabbi.net\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wabbi.net\/index.php\/wp-json\/wp\/v2\/comments?post=39"}],"version-history":[{"count":1,"href":"https:\/\/www.wabbi.net\/index.php\/wp-json\/wp\/v2\/posts\/39\/revisions"}],"predecessor-version":[{"id":40,"href":"https:\/\/www.wabbi.net\/index.php\/wp-json\/wp\/v2\/posts\/39\/revisions\/40"}],"wp:attachment":[{"href":"https:\/\/www.wabbi.net\/index.php\/wp-json\/wp\/v2\/media?parent=39"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wabbi.net\/index.php\/wp-json\/wp\/v2\/categories?post=39"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wabbi.net\/index.php\/wp-json\/wp\/v2\/tags?post=39"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}