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

123
Vistas
Centering ant design carousel on screen

I resized an ant design carousel and would like to move the image to appear on the center of my screen.

This is how the image currently appears enter image description here

This is what I have tried:

    const contentStyle = {
          height: '160px',
          width: '25%',
          color: '#fff',
          lineHeight: '60%',
          textAlign: 'center',
          background: '#364d79',
          justifyContent: 'center',
          alignItems: 'center',
    };

    const imageStyle = {
        flex: 1,
        width: '100%',
        height: '100%',
        resizeMode: 'center',
    }
    return(
    <>
        <Carousel autoplay>
                {
                    [onlineUsers].length === 0 ?
                        <p>There are currently no active users</p>
                        : onlineUsers.map(user => {
                            return (
                            <div className="img-container">
                                <h3 style={contentStyle}><img style={imageStyle} src={user.profile_pic} /></h3>
                            </div>
                            )
                        })
                }
      </Carousel>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can use flex on the image container. It seems at runtime, on the container, display:inline-block is assigned. So we have to use display: flex !important for it to work.

It's also important to put a width & height:auto to image.

CSS

.container {
  display: flex !important;
  justify-content: center;
  background-color: hotpink;
  align-content: center;
}

.container > img {
  width: 80px;
  height: auto;
}

.carousal {
  background-color: brown;
  padding-bottom: 50px;
}

JS

<Carousel className="carousal">
  <div className="container">
    <img src={user} alt="xx" />
  </div>
  <div className="container">
    <img src={programmer} alt="xx" />
  </div>
</Carousel>

I have made a sandbox with two images, different sizes, center aligned.

Edit Scroll automatically - antd@4.21.0 (forked)

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