Clamp.js icon indicating copy to clipboard operation
Clamp.js copied to clipboard

Clamp Text inside anchor tag

Open tomalex0 opened this issue 10 years ago • 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});

tomalex0 avatar Aug 08 '14 18:08 tomalex0

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 avatar Mar 17 '15 17:03 prcaen

@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.

josephschmitt avatar Mar 17 '15 17:03 josephschmitt

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?

stevegrossi avatar Apr 07 '16 16:04 stevegrossi