Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

168
Visualizações
Display last two lines of a large text in a div

I have continuous text added to a div, I want to display only the last two lines of the text in the div which is of fixed width. I could split the large text into multiple lines and then show the last two lines in the div but I was checking if there is any out of the box css property on div that can automatically display only last two lines and hide the rest.

Example:

A printing press is a mechanical device for
applying pressure to an inked surface resting 
upon a print medium (such as paper or cloth),
thereby transferring the ink.

display only:

upon a print medium (such as paper or cloth),
thereby transferring the ink.
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can try like below:

.box {
  width: 280px;
  line-height: 1.2em;
  height: 2.4em; /* twice the line-height */
  overflow: hidden;
  display: flex;
  align-items: end; /* align at the end to see the last lines */
}

.box p {
  margin: 0;
}
<div class="box">
  <p>
    A printing press is a mechanical device for applying pressure to an inked surface resting upon a print medium (such as paper or cloth), thereby transferring the ink.
  </p>
</div>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda