0

jquery.dotdotdot を使用して、カルーセルのタイルの長いテキストを切り捨てています。切り捨ては、期待される結果よりも断続的に切り捨てる場合があります。(たとえば、テキストを 4 行に切り捨てても、ある時点で 3 行に切り捨てられます。)

私の CSS では、以前は 4 行だった式は Max-height = line-height * 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;
        }
4

1 に答える 1

0

コードを投稿していないので、私の最良の提案は次のとおりです。

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

それらが問題を解決するかどうかを確認してください。

ベスト:)

于 2016-03-28T08:53:48.593 に答える