1

This doesn't change it. I don't know why

$("#description").animate({"-webkit-line-clamp":8},500);
console.log($("#description").css("-webkit-line-clamp"))//returns 3

I have also tried

 $("#description").animate({"-webkit-line-clamp":"8"},500);
2
  • at least $("#description").css({"-webkit-line-clamp":"8"}); works. But it's probably a non-animating property, that's why? Commented Oct 31, 2014 at 12:02
  • are you getting any error , warning in console Commented Oct 31, 2014 at 12:03

2 Answers 2

3

Here an example how you could animate it:

$("#description").animate({
    webkitLineClamp: 8
}, {
    duration: 5000,
    step: function (v) {
        $(this).css({webkitLineClamp: parseInt(v,10).toString()});
    }
})
 body {
    padding: 20px;
    font: 1.2em/1.2em'Open Sans', sans-serif;
}
.module {
    width: 250px;
    margin: 0 0 1em 0;
    overflow: hidden;
}
.module p {
    margin: 0;
}
.line-clamp {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<h1>Line Clampin'</h1>




<div id="description" class="module line-clamp">
    <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
</div>

Sign up to request clarification or add additional context in comments.

1 Comment

I just used simple $("#description").animate({ webkitLineClamp: 8 })
2

This page seems to suggest you need display: -webkit-box;

$("#description").css({"display":"-webkit-box"}).animate({"-webkit-line-clamp":8},500);

It also offers up a few alternatives - Clamp.js may offer you a more 'unversal' solution albeit pure JS implementation - but you seem to be going down that route anyway.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.