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

231
Visualizações
Make text in center of div and expand from the middle if there is a lot of text

I have a div witch is a square box and I want it to me in the middle, the more textyou put in it will still be in the middle, I am making my box square with JQuery and would like to center it with css. here is my code:

<div class="project-item" style="background-color:orange;">
                <div class="darkShade">
                    <p>project.TextContent</p>
                    </div>
            </div>

CSS

.project-item {
    width: 33%;
    background-size: cover;
    color: #FFF;
    position: relative;

    .darkShade {
        padding: 2em;
    }



    p {
        opacity: 0;
        transition: 0.2s all;
    }

    form {
        display: flex;
        flex-direction: column;
        position:relative;

        div {
            display: flex;
            flex-direction: row;
            width: 100%;
        }
    }
}



.project-item:hover {
    p {
        opacity:1;
    }
}

JQuery

var cw = $('.project-item').width();
$('.project-item').css({
    'height': cw + 'px'
});

https://jsfiddle.net/su3h76am/4/

Thanks in advance Best regards Max

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Like this? https://jsfiddle.net/vcts5h8o/

  .project-item {
    width: 33%;
    background-size: cover;
    color: #FFF;
    position: relative;
    
    //
    display: flex;
   

    .darkShade {
        padding: 2em;
        
        //
        margin: auto;
        width: max-content;
    }
  }
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