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

161
Vistas
How to superpose elements?

How can i superpose a div with an image? I´m having a div that contains an image and another div, where the div has opacity 0 by default and a opacity of 1 when it hovers. The thing is i have my image and below the hidden div. I want to make my div appear in the center of my image when i hover over and not below.

This is my Post.js:

const Post = () => {
  return (
    <div>
        <div className="postContainer">
            
                <img src={image} alt="profile"/>
                <div className="overlay">
                  <div className="content">
                  <FontAwesomeIcon icon={faHeart} />
                  </div>
                </div>
        </div>
    </div>
  )
}

export default Post

And this is my Post.css

.postContainer{
    height:300px;
    width:300px;
    box-shadow: 0px 0px 2px 1.5px rgba(0, 0, 0, 0.2);    
    margin:10px;
}

.postContainer:hover{
    opacity:.5;
}

.postContainer img{
    /* max-width: 100%;
    max-height: 100%; */
    height:300px;
    width:300px;
}


.overlay{
    opacity: 0;
}

.postContainer:hover .overlay{
    opacity:1;
}
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I would suggest using CSS grid for this

.postContainer{
    height:300px;
    width:300px;
    box-shadow: 0px 0px 2px 1.5px rgba(0, 0, 0, 0.2);    
    margin:10px;

    display: grid;
    place-items: center;
}
.postContainer > * { grid-area: 1/1/-1/-1 }

.postContainer img{
    height: 100%; width: 100%;
    object-fit: cover;
}

.postContainer .overlay{
    opacity: 0;
    z-index: 1;
}


.postContainer:hover img { opacity: .5}
.postContainer:hover .overlay{ opacity: 1 }
about 4 years ago · Santiago Trujillo 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