{"id":649,"date":"2014-08-19T16:07:54","date_gmt":"2014-08-19T16:07:54","guid":{"rendered":"http:\/\/www.nikola-breznjak.com\/blog\/?p=649"},"modified":"2015-08-17T10:58:14","modified_gmt":"2015-08-17T10:58:14","slug":"add-three-dots-in-a-multiline-span","status":"publish","type":"post","link":"https:\/\/nikola-breznjak.com\/blog\/stack-overflow\/add-three-dots-in-a-multiline-span\/","title":{"rendered":"How to add three dots in a multiline span"},"content":{"rendered":"<p><a href=\"http:\/\/stackoverflow.com\/users\/534755\/nikola\"><img loading=\"lazy\" decoding=\"async\" title=\"profile for Nikola at Stack Overflow, Q&amp;A for professional and enthusiast programmers\" src=\"http:\/\/stackoverflow.com\/users\/flair\/534755.png\" rel=\"lightbox[649]\" alt=\"profile for Nikola at Stack Overflow, Q&amp;A for professional and enthusiast programmers\" width=\"208\" height=\"58\" \/><\/a><br \/>\nI&#8217;m a big fan of <a href=\"http:\/\/stackoverflow.com\/\">Stack Overflow<\/a> and I tend to contribute regularly (am currently in the <a href=\"http:\/\/stackexchange.com\/leagues\/1\/alltime\/stackoverflow\/2008-07-31\/534755?sort=reputationchange#534755\">top 0.X%<\/a>).\u00a0In this category (<a href=\"http:\/\/www.nikola-breznjak.com\/blog\/category\/stack-overflow\/\">stackoverflow<\/a>)\u00a0of posts I will will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread <a href=\"http:\/\/meta.stackoverflow.com\/questions\/266971\/can-i-post-so-questions-and-answers-in-a-personal-blog\/266973\">here<\/a>.<\/p>\n<p>So, <a href=\"http:\/\/stackoverflow.com\/questions\/11802361\/add-three-dots-in-a-multiline-span\">my question<\/a>\u00a0was that I actually found the solution to this in another <a href=\"http:\/\/stackoverflow.com\/questions\/11426275\/how-can-i-show-dots-in-a-span-with-hidden-overflow\">StackOverflow question<\/a><span style=\"color: #000000;\">, and that the solution is pretty simple. The link to the jsFiddle for the example is <a href=\"http:\/\/jsfiddle.net\/Y5vpb\/\">here<\/a>, and also copied here\u00a0for reference.\u00a0HTML code:<\/span><\/p>\n<pre class=\"lang:default decode:true \">&lt;span&gt;Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen look&lt;\/span&gt;\u200b<\/pre>\n<p>CSS\u00a0code:<\/p>\n<pre class=\"lang:default decode:true \">span{\r\n    display:inline-block;\r\n    width:180px;\r\n    white-space: nowrap;\r\n    overflow:hidden !important;\r\n    text-overflow: ellipsis;\r\n}<\/pre>\n<p>And it works like <strong>expected<\/strong>, it prints: <strong>Lorem Ipsum is simply du&#8230;<\/strong><\/p>\n<p>However, when I tried this in another example. JsFiddle is <a href=\"http:\/\/jsfiddle.net\/9HRQq\/\">here<\/a>. HTML code:<\/p>\n<pre class=\"lang:default decode:true \">&lt;div class=\"textContainer\"&gt;                \r\n    &lt;img src=\"#\" class=\"image\" alt=\"the_image\"&gt;\r\n    &lt;span class=\"text\"&gt;\"The quick brown fox jumps over the lazy dog\" is an english-language pangram, that is, a phrase that contains all of the letters of the English alphabet. It has been used to test typewriters and computer keyboards, and in other applications involving all of the letters in the English alphabet. Owing to its brevity and coherence, it has become widely known.&lt;\/span&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>CSS code:<\/p>\n<pre class=\"lang:default decode:true \">.textContainer{\r\n    width: 430px;\r\n    float: left;\r\n    margin-top: 10px;\r\n    border: 1px solid black;                \r\n}\r\n\r\n.text {\r\n    font-size: 24px;\r\n    line-height: 24px;\r\n    font-weight: bold;\r\n    color: #047F04;\r\n    display: block;\r\n    white-space: normal;\r\n    overflow: hidden !important;\r\n    text-overflow: ellipsis;\r\n    height: 99px;\r\n}\r\n\r\n.image {\r\n    float: right;\r\n    position: absolute;\r\n    top: 85px;\r\n    right: 10px;\r\n    width: 108px;\r\n    height: 42px;\r\n}<\/pre>\n<p>So my question was\u00a0how could I achieve to put <strong>&#8230;<\/strong> on the end of the string in my example?<\/p>\n<p>The answer, by user devundef, was:<\/p>\n<blockquote>\n<p style=\"color: #000000;\">The specification for the\u00a0<code>text-overflow<\/code>\u00a0property says that this is not possible for multiline text:<\/p>\n<blockquote style=\"font-style: normal; color: #000000;\"><p>This property specifies rendering when\u00a0<strong>inline content<\/strong>\u00a0overflows its block container element (&#8220;the block&#8221;) in its inline progression direction that has \u2018overflow\u2019 other than \u2018visible\u2019. Text can overflow for example when\u00a0<strong>it is prevented from wrapping<\/strong>\u00a0(e.g. due to \u2018white-space:nowrap\u2019 or a single word is too long to fit).<\/p><\/blockquote>\n<p style=\"color: #000000;\">In other words, only works on single line text blocks.<\/p>\n<p style=\"color: #000000;\">source:\u00a0<a style=\"color: #4a6b82;\" href=\"http:\/\/dev.w3.org\/csswg\/css3-ui\/#text-overflow\">http:\/\/dev.w3.org\/csswg\/css3-ui\/#text-overflow<\/a><\/p>\n<p style=\"color: #000000;\"><strong>EDIT<\/strong>\u00a0This fiddle has a workaround using jquery:\u00a0<a style=\"color: #4a6b82;\" href=\"http:\/\/jsfiddle.net\/k5VET\/\">http:\/\/jsfiddle.net\/k5VET\/<\/a>\u00a0(source:\u00a0<a style=\"color: #4a6b82;\" href=\"http:\/\/stackoverflow.com\/questions\/3404508\/cross-browsers-mult-lines-text-overflow-with-ellipsis-appended-within-a-widthhe\">Cross browsers mult-lines text overflow with ellipsis appended within a width&amp;height fixed div?<\/a>)<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%).\u00a0In this category (stackoverflow)\u00a0of posts I will will be posting&hellip;<\/p>\n","protected":false},"author":1,"featured_media":609,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[],"class_list":["post-649","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-stack-overflow"],"_links":{"self":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/649","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/comments?post=649"}],"version-history":[{"count":6,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/649\/revisions"}],"predecessor-version":[{"id":1716,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/649\/revisions\/1716"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/media\/609"}],"wp:attachment":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/media?parent=649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/categories?post=649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/tags?post=649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}