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

112
Views
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 answers
Answer question

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 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!