I am trying to add ellipsis to several multi-line paragraphs on my site when they exceed a certain height. For this I use dotdotdot , the jquery plugin.
The strange thing is that it does not work when I refresh the page. It only works after resizing the window (and then it works fine). I already put all the scripts at the end of my html, so dotdotdot loads last, but it still does not work properly. Does anyone know why this will happen?
I use these settings for dotdotdot:
$(document).ready(function() { $("p.article-content").dotdotdot( { ellipsis : '...', wrap : 'word', after : null, watch : true, height : null, tolerance : 0, callback : function( isTruncated, orgContent ) {}, lastCharacter : { remove : [ ' ', ',', ';', '.', '!', '?' ], noEllipsis : [] } }); });
Corresponding HTML (it's ugly, I know, I'm still experimenting with it):
<article class="article"> <div class="article-image"></div> <h2>Title</h2> <p class="date">December 19, 2012</p> <p class="article-content">Lorem ipsum etc. (the actual content is larger)</p> </article>
And CSS:
article { font-size: 99%; width: 28%; line-height: 1.5; float: left; margin-left: 8%; margin-bottom: 3em; text-align: justify; } article h2 { font-size: 125%; line-height: 0.5; text-transform: uppercase; font-weight: normal; text-align: left; color: rgba(0,0,0,0.65); } .date { margin-top: 0.3em; margin-bottom: 1em; font-family: 'PT Sans'; color: rgba(0,0,0,0.5); } .article-image { background-image: url(http://lorempixel.com/g/400/300/city/7); width: 100%; height: 13em; overflow: hidden; margin-bottom: 1.5em; } p.article-content { font-family : 'PT Sans'; color : rgba(0,0,0,0.65); margin-bottom : 0; height : 7em; overflow : hidden; }