I need assistance in structuring my Team section with multiple rows, each containing 5 cards. I have a list of team members that I want to display in this format using a single array and loop. However, I am struggling to figure out how to automatically create new rows when one row is filled with 5 cards.
Currently, I manually created 3 different arrays for 3 rows, but the goal is to achieve this layout efficiently using a Single Array and Single Loop.
const teamDataOne = [
{
img: "img/team/man.png",
name: "Bimal Timilsina",
position: "Web Designer",
facebook: "https://facebook.com/",
email: "mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="13607c7e767c7d7653747e727a7f3d707c7e">[email protected]</a>"
},
// Additional team members...
];
const container = document.getElementById("teamRowOne");
teamDataOne.forEach(result => {
const content = `
<div class="col-md-2 shadow p-3 mb-5 bg-white rounded ">
<img src="${result.img}" height="150" width="150" alt="name">
<h4>${result.name}</h4>
<h6>${result.position}</h6>
<div class="border-bottom"></div>
<a href="${
result.facebook
}" target="_blank" class="btn-social btn-facebook"><i class="fa fa-facebook"></i></a>
<a href="${
result.email
}" target="_blank" class="btn-social btn-email"><i class="fa fa-envelope"></i></a>
</div>
`;
container.innerHTML += content;
});
Below is a snippet of the HTML code:
<div class="row justify-content-around wow zoomIn" id="teamRowOne">
</div>
The desired outcome is to have only five cards aligned in each row.