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

110
Vistas
Using sections inside flexbox image gallery

I'm trying to create an image gallery using a flexbox layout. This is how it's supposed to look in the end:

enter image description here

This is basically just a flexbox with images inside:

<div class="flexbox-grid">
    <img src="https://i.imgur.com/DjLPhu1.png">
    ...
 </div>

.flexbox-grid {
   display: flex;
   flex-wrap: wrap;
}
  
img {
   margin: 10px;
}

But now I want to add sections to groups of images for some js scripts. Like this:

<section id="first">
    <img src="https://i.imgur.com/DjLPhu1.png">
</section>
<section id="second">
    <img src="https://i.imgur.com/DjLPhu1.png">
    <img src="https://i.imgur.com/DjLPhu1.png">
    <img src="https://i.imgur.com/DjLPhu1.png">
</section>

Of course this completely messes up the grid layout, as now the grouped images are kept together: enter image description here

How do I add sections (or divs) here and still keep the initial grid layout? The elements I actually want to have a flexbox for are the children of the sections, not the sections themselves.

Here's the code: https://jsfiddle.net/8f2mv7cb/1/

Thank you in advance.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think this would be more of a task for CSS grid layout. Then you could arrange the rows and columns to fit how you want it and give classes to them or certain parts of it which gives your scripts more freedom.

https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout

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