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

142
Visualizações
Text without certain length in two different divs

First things first!

Ingredients: two divs aligned horizontally (each has 50% the width of the parent) and some text to put in the first div (left) and then, if overflowing, in the second one (right). The divs are 200px tall.

The text comes from a PHP script that echoes a variable (<p><?php echo $foo; ?></p>) which contains all the text. In brackets I wrote a <p> tag. The DOM looks something like this:

<div class="thecontainer">
    <div class="theleftone">
        <p><?php echo $avariablewithsometext; ?> </p>
    </div>
    <div class="therightone">
        <!-- everything is permitted -->
    </div>
 </div>

Problem: I'm trying to achieve this goal using CSS flex properties but I can't find a way to put the overflowing text from the first div in the second one.

Question: How can I put the overflowing text in the second div leaving the PHP-script clean?

Actual Demo:

.thecontainer{
  width:100%;
  height:100px;
  overflow: hidden;
  display: block;
}

.therightone {
    background-color: red;
    width: 50%;
    height:100px;
    display: block;
    float:right;
}
.theleftone {
   background-color: blue;
   width: 50%;
   height:100px;
   display:block;
   float: left;
}
<div class="thecontainer">
    <div class="theleftone">
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do iusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex </p>
    </div>
    <div class="therightone">
        <!-- everything is permitted -->
    </div>
 </div>

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

you can use CSS3 columns

.thecontainer {
  width: 100%;
}

.theleftone {
  background-color: lightblue;
  columns: 2;
}

p {
  margin: 0
}
<div class="thecontainer">
  <div class="theleftone">
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do iusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex </p>
  </div>
</div>

about 4 years ago · Santiago Trujillo 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