josephschmitt/Clamp.js

Clamp Text inside anchor tag

Opened this issue · 3 comments

I'm trying to clamp data inside anchor tag which in turn inside header, but it was not working as expected

I'm i doing the right way ?

HTML

<h1><a id="mylink" href="#"> Curabitur magna lectus, cursus at euismod sed, aliquet a lectus. Vivamus ac magna purus, in eleifend eros.</a></h1>

JS

var header = document.getElementById('mylink');
$clamp(header, {clamp: 2, useNativeClamp: false});

Hello @tomalex0 this is because your anchor is not display: block.

View this jsfiddle : http://jsfiddle.net/d3o2w1uu/

@josephschmitt : could you add this in README.md ?

Thanks

@prcaen hmm, smells like a bug. I don't see why the anchor has to be block for this to work. I'll see if I can look into that issue directly instead. Glad there's a workaround for now.

I've noticed that clamp.js works on display: inline elements in Chrome, but not Firefox. In Firefox, it only works if the element it's called on is display: block. Perhaps an issue with non-native clamping?