2016-03-28 13 views
0

jquery.dotdototを使用して、カルーセルのタイルの長いテキストを切り捨てます。切捨ては、断続的に、予想される結果よりも切り捨てられます。 (例えば4行にテキストを切り捨てるが、いくつかの点で、それはわずか3行に切り捨てられます。)Jquery.dotdototを使用した断続的な切り捨て

私のCSSで私は4つのラインを持っているために使用される式は、最大高さ=行の高さ* 4

です応答を感謝します。ありがとう。 JS:

$(document).ready(function() { 
       EllipsisConfigFunction($(".module-body.dot-ellipsis")); 

    function EllipsisConfigFunction($elements) { 
     $elements.each(function() { 
      var $element = $(this); 
      $element.dotdotdot({ 
       // configuration goes here 
       ellipsis: '... ', 

       /* How to cut off the text/html: 'word'/'letter'/'children' */ 
       wrap: 'word', 

       /* Wrap-option fallback to 'letter' for long words */ 
       fallbackToLetter: true, 

       /* jQuery-selector for the element to keep and put after the ellipsis. */ 
       after: null, 

       /* Whether to update the ellipsis: true/'window' */ 
       watch: true, 

       /* Optionally set a max-height, can be a number or function. 
        If null, the height will be measured. */ 
       height: null, 

       /* Deviation for the height-option. */ 
       tolerance: 0, 

       /* Callback function that is fired after the ellipsis is added, 
        receives two parameters: isTruncated(boolean), orgContent(string). */ 
       callback: function (isTruncated, orgContent) { }, 

       lastCharacter: { 

        /* Remove these characters from the end of the truncated text. */ 
        remove: [' ', ',', ';', '.', '!', '?'], 

        /* Don't add an ellipsis if this array contains 
         the last character of the truncated text. */ 
        noEllipsis: [] 
       } 
      }); 
     }); 
    } 
    }); 

はCSS:

.module-body{ 
      max-height: 80px; 
      overflow: hidden; 
      position: relative; 
      text-align: left; 
      line-height:20px; 
     } 

答えて

0

あなたのコードのいずれかの私の最高の提案を投稿していないので、は、次のとおりである:これらの修正はあなたの問題ならば

https://css-tricks.com/snippets/css/truncate-string-with-ellipsis/ 
https://api.jquery.com/jQuery.trim/ 
http://stackoverflow.com/a/4637957/5833940 

を参照してください。

ベスト:

+0

ありがとう@ SG1Asgard。私はコードで質問を更新しました。提案をありがとうが、私はクロスブラウザの複数行の省略記号が必要です。感謝します。 –

関連する問題