Creating a loop using Bootstrap cards is my goal

I am facing an issue with the layout of my page. Whenever I create an "event", the cards appear stacked on top of each other instead of side by side. Is there a way to limit the number of cards per row using a loop or CSS?

eventList.jsp

<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="All" role="tabpanel"
            aria-labelledby="home-tab">
            <c:if test="${allList.size() == 0}" var="event" scope="session">
                <h4 class="text-center py-3 empty-events">
                    <i class="far fa-folder-open"></i> No event
                </h4>
            </c:if>
            <div class="col-md-5">
                <c:forEach var="event" items="${allList}">
                    <br>
                    <div class="card">
                        <img class="card-img-top img-fluid"
                            src="resources/img/all.jpg" alt="">
                        <div class="card-body">
                            <h4 class="card-title text-center">${event.title}</h4>
                            <hr>
                            <h5 class="card-title">${event.description}</h5>
                            <p class="card-text">
                                <b><i class="far fa-calendar-alt"></i> Date: ${event.date}</b>
                            </p>
                            <p class="card-text">
                                <b><i class="fas fa-male"></i> Manager:
                                    ${event.username}</b>
                            </p>
                        </div>
                        <div class="col text-center">
                        <a href="eventDetails?id=${event.id}" class="btn btn-danger"><i
                            class="fas fa-external-link-alt"></i> Open</a>
                        </div>
                        <br>
                    </div>
                </c:forEach>
            </div>
        </div>
  ........
 </div>

Answer №1

Here is the resolution I discovered:

<div class="tab-content" id="myTabContent">
        <div class="tab-pane fade show active" id="All" role="tabpanel"
            aria-labelledby="home-tab">
            <c:if test="${allList.size() == 0}" var="event" scope="session">
                <h4 class="text-center py-3 empty-events">
                    <i class="far fa-folder-open"></i> No event
                </h4>
            </c:if>
        <div class="row">
            <c:forEach var="event" items="${allList}">
                <div class="col-md-4">
                    <br>
                    <div class="card">
                        <img class="card-img-top img-fluid"
                            src="resources/img/all.jpg" alt="">
                        <div class="card-body">
                            <h4 class="card-title text-center">${event.title}</h4>
                            <hr>
                            <h5 class="card-title">${event.description}</h5>
                            <p class="card-text">
                                <b><i class="far fa-calendar-alt"></i> Date:</b> ${event.date}
                            </p>
                            <p class="card-text">
                                <b><i class="fa fa-user"></i> Manager:</b>
                                    ${event.username}
                            </p>
                        </div>
                        <div class="col text-center">
                        <a href="eventDetails?id=${event.id}" class="btn btn-danger"><i
                            class="fas fa-external-link-alt"></i> Open</a>
                        </div>
                        <br>
                    </div>
                </div>
            </c:forEach>
        </div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Discovering the reason behind a DOM element's visual alteration upon hovering: Where to start?

Visit this page, then click on the next button to navigate to the time slots section. As you hover over any time slot, you will notice a change in appearance. Despite inspecting Chrome's developer tools, I was unable to locate a style with a hover dec ...

Can you customize the background color for the entire section where the first child appears in a nested collapsible list with CSS?

In my current setup, I have a nested list within a larger container box. Each ul element has a border-top style applied, while each li element has a border-bottom and padding. The HTML code looks like this: <div class="menu"> <ul ...

Designing a dynamic button with changing colors using html and css

Is there a way to design a button with a starting color of red, but changes to orange when the mouse hovers over it? I am looking to add this type of button to my website. ...

Issues with jQuery Ajax sending Post data to PHP script

I've been attempting to transfer variables from my JavaScript to a PHP file using AJAX, but for some reason, it's not functioning as expected. Despite researching numerous similar queries, I have yet to come across a solution. Here is an excerpt ...

Creating a website does not involve refreshing my CSS packages

After running my code from Visual Studio in release mode and reviewing the bundled style sheet, I noticed that my updates to the CSS files are reflected in the bundle. However, upon publishing the website to either the server or my local machine, the chang ...

Uncovering classes and selectors in CSS files that match an element with JavaScript

Trying to explain my idea with an example since it's a bit tricky. Imagine we have this HTML code: <ul> <li id="myli" class="myclass">Hello</li> </ul> along with the corresponding CSS: .myclass{ color:red; } li.m ...

Resizing and adaption of Div elements

There's a challenging issue I've been facing and I can't find a way around it. What I'm trying to achieve is a responsive design where both the menu and text resize seamlessly when the resolution changes or when there's a zoom in/ ...

Extracting text from HTML elements using BeautifulSoup

I'm working with the following html code and I want to extract the text that comes after <b>Name in Thai</b>, specifically : this is what I want content = """ <html><body><b>Name of Bangkok Bus station:</b> <spa ...

Selecting multiple options in a dropdown menu in React Bootstrap

I'm currently working on incorporating a multi-select feature (similar to select all and deselect all) in a React Bootstrap dropdown menu. <Dropdown> <Dropdown.Toggle variant="success" id="dropdown-basic"> Dropdow ...

The Page Transcends the Boundaries of the HTML Tag

This particular issue sets itself apart from the common overflow problems that are often faced by people. Interestingly, I have only encountered this problem while using Chrome (Version 41.0.2272.101 64-bit). IE 9+ and Firefox, on the other hand, seem to b ...

Looking for a way to upload only part of a large file using HTML and PHP

Is it possible to create a PHP script that can upload only the first 1 MB of a very large file? Can this be achieved with a standard form upload in PHP by closing off the connection after 1 MB is uploaded? I have researched various uploaders (HTML5/Java ...

Struggling to make the webpage appear full width when resizing

Whenever I resize the browser window, I notice that the header and navigation bar do not fill up the entire width of the browser. This can be seen when shrinking the browser size. Ideally, I would like both the header and navigation bar to stretch till the ...

What is the alternative name for DOM elements in TypeScript?

When working with a HTMLImageElement, I can simply reference it like this: let image: HTMLImageElement; ... In Dart, importing the dom is possible using: import 'dart:html' as dom; Using 'dom' as an alias for the "dart:html" package. ...

Unique Title: "Personalized Styling Category for dijit/layout/ContentPane"

I am looking to add a custom CSS Class to a dijit/layout/ContentPane in order to apply my own styling. This is because I have multiple tabs in a TabContainer where my ContentPanes are located and I want to avoid duplicating borders. Adding a border around ...

adjustable: n with a variety of n items

I'm currently working on a component that involves circles and lines, and I'm trying to gain a better understanding of how flexbox works its magic. Specifically, I want to dive deeper into the flex property. Visually, all three versions have the ...

Cannot adjust Span content with JQuery

I am currently utilizing Bootstrap and JQuery for my project. HTML <div> <ul> <li><strong> Status : </strong><span id="monitorStatusSpan">1111</span></li> </ul> </div&g ...

What is causing the data element to remain unchanged within a Vue.js function and what steps can be taken to ensure its value can be updated?

Using the axios API in the created() function, I am able to access webURLs. When a mouseover event triggers a v-for handler in the HTML file, the index is obtained and assigned to the selectedState data element. Although the value of selectedState changes ...

Tips for nesting React components within a grid layout

For my News website, I have a component that showcases articles fetched from an API in a grid format. Additionally, I also have a separate component dedicated to displaying the Latest News. I am looking for a way to position the Latest News widget within t ...

The current limitation of the Dev.to API restricts the display of only the most recent

For the past 3 years, I've integrated Dev.to's public API into my portfolio to display all of my articles. However, after transitioning my entire portfolio to ReactJS and SaSS from native HTML, CSS, and JS, it now only shows my latest 30 articles ...

The line height appears slightly smaller in Firefox compared to Webkit

Here is the CSS code I am using: .btn_container { cursor: pointer; font-family: Tahoma,Verdana,Arial; font-size: 11px; padding: 0; width: auto; } .btn_center { background: blue; color: #FFFFFF !important; display: block; float: left; font-weight: bold; h ...