Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

232
Views
long text 4 lines and in last line if have ellipsis add "Read more" link , it's possible?

I need to display text from array I did it with ng-repeat and when the text bigger then 4 lines add ellipsis and link view more I did the ellipsis and also function that return if there are ellipsis and then I display link but its going down a row. I wanna find way to do it... the situation now I would love for you to help me. Attached is html,js code

  <div class="comment1 aop-ellipssis four">
            {{item.description}}
          </div>
          <span ng-if="c.isOverflown('comment1',$index)" ng-click="c.openLink(item.sys_id)" class="ag-link" >View More</span>



`   function _isOverflown(elem,index){
    var element = angular.element('.'+elem)[index];
    return element.scrollHeight > element.clientHeight ;}
`

This is what I did but can not raise the view more Because I have defined width and according to that I am shown the three points

I need such a result

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

here is a possible average trick , keep some space for that link and set it in absolute position inside a relative parent where stands the text to clamp :

demo below , that fails to hide the motre link if text is filling partially the last line without ellipsis.


edit : to match your screenshot you added, javascript is there for such a job, CSS won't help I'll leave the answer here for curiosity only. :)


div {
  width: 400px;
  margin: 1em auto 0;
  line-height: 1.4;
  border-top: solid;
  padding-bottom: 1.4em;/* == line-height */
  position: relative; /* for coordonate reference to position the more link */
  overflow:hidden;/* hide a if here and  too far from top */
}

div p { /* text-clipping*/
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  margin: 0;
}

div p+a {
  position: absolute;
  top: 4.2em;/* == line-height x line-clamp  */
  right:1rem;
  background:#bee
}
<div>
  <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est.
    Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus
    lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor,
    facilisis luctus, metus</p><a href="#">more</a>
</div>
<div>
  <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p><a href="#">more</a>
</div>

<div>
  <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet.</p><a href="#">more that should not be seen </a>
</div>
<div>
  <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est.
    Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. </p><a href="#">more</a>
</div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!