html - javascript/angularjs cut string to fit in a div -
in angularjs/ionic mobile application have implemented list of messages. want modify it, if message text wider div container should cut string , adds 3 dots.
my message list looks this:
<ion-list ng-repeat="message in messages"> <ion-item can-swipe="true" class="item-icon-left item-icon-right"> <i class="icon ion-email-unread"></i> <div class="row"> <span class="col col-50"> <h2>{{message.title}}</h2> </span> <span class="col col-50 content-right text-small"> {{message.datestring}} </span> </div> <div class="row"> <span class="col text-small"> {{message.text}} </span> </div> <i class="icon ion-chevron-right"></i> <ion-option-button class="button-dark"> more </ion-option-button> <ion-option-button class="button-assertive"> delete </ion-option-button> </ion-item> </ion-list>
how can dynamically, depends on width of device/container?
you don't js.
simply use css's overflow
, text-overflow
properties:
div { width: 50px; overflow: hidden; text-overflow: ellipsis; }
<div>1234567890123456789012345678901234567890</div>
Comments
Post a Comment