Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

222
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda