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

314
Views
Cómo reemplazar tres puntos agregados por -webkit-line-clamp con el texto "leer más"

Estoy usando -webkit-line-clamp para truncar texto como el siguiente ejemplo

 .box { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; width: 100px; }
 <div class="box"> <p>Hey, don't cut me off like that. I want to speak my mind and don't appreciate being put into a box.</p> </div>

Aquí obtengo 3 puntos al final del truncamiento, quiero tener un enlace " leer más " al final del texto truncado en lugar de ... . Por favor, hágame saber si esto se puede lograr a través de css o JS

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

0

¿Qué tal este código? Este código elimina el botón cuando no se desborda .

 var container = document.getElementsByClassName('container'); var i; for (i=0;i<container.length;i++) { if (container[i].firstElementChild.scrollHeight<=container[i].firstElementChild.clientHeight) { container[i].lastElementChild.style.display = 'none'; } } function more(x) { var box = x.parentElement.firstElementChild; if (!box.classList.contains('box-more')) { box.classList.add('box-more'); x.innerHTML = "Close"; } else { box.classList.remove('box-more'); x.innerHTML = "Read More"; } }
 .box { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; width: 100px; } .box-more { -webkit-line-clamp: unset !important; }
 <div class="container"> <div class="box"> <p>Hey, don't cut me off like that. I want</p> </div> <button onclick="more(this)">Read More</button> </div> <div class="container"> <div class="box"> <p>Hey, don't cut me off like that. I want to speak my mind and don't appreciate being put into a box.</p> </div> <button onclick="more(this)">Read More</button> </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!