Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
Cómo expandir a maxWidth con alignSelf establecido

El siguiente código expande correctamente el max-width de un div:

 <div style="display: flex; flex-direction: column;"> <div style="max-width: 500px;"> <div style="background-color: red; height: 20px;"></div> </div> </div>

Resultado: ingrese la descripción de la imagen aquí

Sin embargo, cuando configuro cualquier alineación, align-items en el div más primario, align-self en el div max-width , etc., ya no se usará maxWidth y el ancho real se establecerá en 0.
Por ejemplo:

 <div style="display: flex; flex-direction: column;"> <div style="max-width: 500px; align-self: center"> <div style="background-color: red; height: 20px;"></div> </div> </div>

Produce una pantalla en blanco:

ingrese la descripción de la imagen aquí

¿Cómo alineo el div (en el centro, por ejemplo) y mantengo su ancho intacto? El objetivo no es recurrir al uso de width , porque eso no se ajustará al ancho principal (que puede ser cualquier cosa). Cualquier solución que mantuviera el ancho, pero que no insistiera en tomarlo incluso si no hay espacio, como con width , funcionaría.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Con align-self:center y flex-direction:column , debe establecer el ancho del contenedor interno, lo cual hice para que sea del 100 % y ahora se muestra.

 <div style="display: flex; flex-direction: column;background-color:grey"> <div style="max-width: 500px; align-self: center; width:100%;background:black;"> <div style="background-color: red; height: 20px;"></div> </div> </div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!