Multiple lines of text ellipsis
HTML:
<div id="app">
Test Something ! <span>label</span><span>label2</span>
</div>
CSS:
#app {
width: 100px
}
JavaScript:
var app = document.getElementById('app')
TextCliper.clip(app, 1)
Result:
<div id="app" style="word-wrap: break-word;">
Test Something ! <span>l...</span>
</div>
Using NPM:
npm install textcliper --save
Using CDN:
<script type="text/javascript" src="//unpkg.com/textcliper"></script>
// using cdn
var app = document.getElementById('app')
TextCliper.clip(app, 1)
// or using npm
import TextCliper from 'textcliper'
TextCliper.clip(app, 1)
// or vue plugin, if you use Vue
import TextCliper from 'textcliper'
Vue.use(TextCliper)
// vue instance method
this.$textclip(1)
// vue directive
<div v-textclip="1"> Test Something ! <span>label</span><span>label2</span> </div>
a TextCliper
instance
ele
: target dom element.
options
: when it is a number, it indicates the number of rows ellipsis.
options.lines
: specifies the number of rows to ellipsis.
options.sign
: ellipsis symbol, the default is ...
.
This project is licensed under the MIT License - see the LICENSE file for details