Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiline text overflow (dotdotdot): wrap only word

I have such example of my code:

  <div class="container">
    <div class="item n1">Proe Schugaienz</div>
    <div class="item n2">Proe Schugaienz</div>
  </div>

and i use such jQuery code:

$('.item').dotdotdot({
  wrap: 'word',
  fallbackToLetter: false
})

and css:

.item {
  margin: 5px;
  background: red;
  padding: 2px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.n1 {
  width: 8px;
}

.n2 {
  width: 80px;
}

but as result i get:

enter image description here

as result i want achieve this:

enter image description here

is it possible with pure css or with dotdotdot.js? if word (sentence) cannot match it's parent: then show only default one-line-text-overflow if word (sentence) is able to fit parent word-by-word - then match it, no letter-hyphenation!

so i don't wanna my container to be extented by height (i have a lot of data, it's only an example, i could not hardcode some blocks)

https://plnkr.co/edit/IxS0CReJicRfDdeGpoPo?p=preview

like image 418
brabertaser19 Avatar asked Dec 21 '15 16:12

brabertaser19


1 Answers

you can use flex

<div class="container">
 <span></span>
 <em></em>
</div>
.container {
   display: flex;
   justify-content: center; /* centers content horizontally*/
   align-items: center /* centers content vertically*/
}
like image 100
dorindo Avatar answered Sep 20 '22 20:09

dorindo