![]() ![]() ![]() ![]() The is a very common and widely used scenario and it has a standard CSS implementation. Truncating single line text followed by an ellipsis There a JavaScript solution might be ideal in some cases. $("p").Truncating multiple line text using pure CSS can be done, however, it has some caveats. Var calc = parseInt(articleheight/lineheight) Var articleheight = $('article').height() Var lineheight = parseFloat($('p').css('line-height')) What the strag will think is that any man who can hitch the length and breadth of the galaxy, rough it, slum it, struggle against terrible odds, win through, and still knows where his towel is is clearly a man to be reckoned with. Furthermore, the strag will then happily lend the hitch hiker any of these or a dozen other items that the hitch hiker might accidentally have "lost". For some reason, if a strag (strag: non-hitch hiker) discovers that a hitch hiker has his towel with him, he will automatically assume that he is also in possession of a toothbrush, face flannel, soap, tin of biscuits, flask, compass, map, ball of string, gnat spray, wet weather gear, space suit etc., etc. More importantly, a towel has immense psychological value. Partly it has great practical value - you can wrap it around you for warmth as you bound across the cold moons of Jaglan Beta you can lie on it on the brilliant marble-sanded beaches of Santraginus V, inhaling the heady sea vapours you can sleep under it beneath the stars which shine so redly on the desert world of Kakrafoon use it to sail a mini raft down the slow heavy river Moth wet it for use in hand-to-hand-combat wrap it round your head to ward off noxious fumes or to avoid the gaze of the Ravenous Bugblatter Beast of Traal (a mindboggingly stupid animal, it assumes that if you can't see it, it can't see you - daft as a bush, but very ravenous) you can wave your towel in emergencies as a distress signal, and of course dry yourself off with it if it still seems to be clean enough. A towel, it says, is about the most massivelyuseful thing an interstellar hitch hiker can have. } The Hitch Hiker's Guide to the Galaxy has a few things to say on the subject of towels. Truncating multiple line text using pure CSS can be done, however, it has some caveats. ![]() I have this JSFiddle to illustrate the issue. Maecenas scelerisque sodales ipsum a hendrerit. In massa ipsum, bibendum quis lorem et, volutpat ultricies nisi. Mauris vestibulum, eros ac ultrices lacinia, justo est faucibus ipsum, sed sollicitudin sapien odio sed est. Quisque bibendum sem at bibendum suscipit. Nunc sollicitudin lorem eget eros eleifend facilisis. Suspendisse fermentum suscipit eros, ac ultricies leo sagittis quis. Maecenas vitae quam ac mi venenatis vulputate. Proin arcu diam, tempus ac vehicula a, dictum quis nibh. Aliquam dignissim velit sed nunc imperdiet cursus. Vivamus vitae pharetra nisl, eget fringilla elit. Maecenas scelerisque sodales ipsum a hendreritLorem ipsum dolor sit amet, consectetur adipiscing elit. } Lorem ipsum dolor sit amet, consectetur adipiscing elit. Multiple lines truncation overflow: hidden text-overflow: ellipsis - optional, it will add three dots at the end of the trimmed line display: -webkit-box. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |