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

215
Views
How to make content display in three columns instead of one column?

I am a beginner and learning from a tutorial using an API. I would like to change the layout of the design, and instead of having one column, I would like a three column layout. I don't know if I am using flexbox correctly.

I have tried using row and then having three columns, but somehow its not displaying correctly.I am also using bootstrap.

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

0

What you're looking for is CSS Grid, which lets you display elements in rows and columns.

Just change your flexbox to a grid with 3 equal columns:

/* display: flex; */
display: grid;
grid-template-columns: repeat(3, 1fr);
about 4 years ago · Juan Pablo Isaza Report

0

first of all, we need to clean up your HTML structure.

since in your javascript you are appending all of the cards in a class "images-container" we have to remove the duplicate divs.

<div class="container-fluid">
    <div class="row">
      <div class="col-md-4">
        <div class="images-container"></div>
      </div>
      <div class="col-md-4">
        <div class="images-container"></div>
      </div>
      <div class="col-md-4">
        <div class="images-container"></div>
      </div>
    </div>
  </div>

and turned them into. so it will only appended into a single container and do our flex there.

  <div class="container-fluid">
    <div class="row">
      <div class="images-container"></div>
    </div>
  </div>

The next one is CSS, I added a "flex-wrap: wrap" on the "images-container" so that the cards will go into the next line whenever there is no space left.

/* Images Container */
.images-container {
  width: 100%;
  margin-top: 50px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
}

and since you are following bootstrap class names you have to add media queries on classnames with breakpoints so. it says the card will take 12 columns on xs "smallest screen" and 4 columns on medium screen.

.col-xs-12 { 
  width: 100%;
}

@media onyl screen and (min-width: 767px) {
  .col-md-4 {
    width: 33% !important;
  }
}

now on javascript. since we got our cards inside "images-container". then we need to add the classname "col-md-4" and "col-xs-12" on the card directly so it will have it's own width

    // Card Container
    const card = document.createElement("div");
    card.classList.add("card");
    card.classList.add("col-md-4");
    card.classList.add("col-xs-12");

sorry for the long explanation I'm still improving my explanation skills hopefully it will help you out.

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!