Overflowing Padding and Margin in Bootstrap Card Column

Is there a solution to prevent padding overflow in the Bootstrap Card Column when trying to split a dictionary of items into three columns? The issue is that the padding from bottom rows spills into the top of the next column (refer to col1->col2).

View image example

Below is the code snippet:

<div class='container p-2 mt-2 mb-4 rounded shadow-lg' style='background-color: #d3b273;'>
            <!-- Dropdown -->
            <div class="btn-group w-100 pb-2">
                <input type="text" autocomplete="off" class="form-control border-secondary text-center col-10" value={{selected_agency}}>
                <button type="button" id="agency_dropdown_menu" class="btn dropdown-toggle dropdown-toggle-split col-2 bg-white rounded border-secondary" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
                <div class="dropdown-menu border-secondary w-100 dropdown-menu-right scrollable-menu">
                    {% for agency in agencies %}
                        <button class="dropdown-item border-secondary" name='agency-button' type="submit" value='{{agency}}'>{{agency}}</button>
                    {% endfor %}
                </div>
            </div>
            <!-- Fields and values -->
            <div class='card-columns pb-2'>
                {% for field in headers %}
                {% with agency_dict|dictionarylookup:field.name as val %}
                {% ifequal val "" %}
                {% else %}
                <div class="d-flex flex-row card_" style='display: inline-block;'>
                    <div class='d-flex flex-row p-2 m-1 rounded' style='background-color: #8f6e2d; display: inline-block;'>
                        <h4 class='mb-1 mr-3 text-center text-white'>{{field.verbose_name}}:</h3>
                        <p class='m-0 align-self-center' style='color: #edd290;'>{{agency_dict|dictionarylookup:field.name}}</p>
                    </div>
                </div>
                {% endifequal %}
                {% endwith %}
                {% endfor %}
            </div>
        </div>

<style>
.card-columns {
    column-count: 3;
}
</style>

Answer №1

Utilizing Bootstrap's card-columns requires using child classes of card, which will automatically adjust to fill their respective column.

The recommended approach for implementing card-columns is to wrap your content in a container with the card class.

<div class="card-columns">

  <div class="card" style='background-color: #8f6e2d'>
      <div class='d-flex flex-row p-2 m-1'>
        <h4 class='mb-1 mr-3 text-center text-white'>{{field.verbose_name}}:</h4>
        <p class='m-0 align-self-center' style='color: #edd290;'>{{agency_dict|dictionarylookup:field.name}}</p>
      </div>
    </div>

</div>

While this solution addresses the issue of cards overflowing into another column, it may not achieve the exact visual outcome you desire.

Considering your specific design requirements, Bootstrap card-columns might not be the most suitable choice based on your provided screenshot.

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

What is the best way to determine the maximum `width` in a `translateX` animation?

I'm looking to design something similar to a desktop-only carousel. Here's the code snippet I have: <div class="wrapper"> <div class="image-container"> <img alt="Siac" src="https://diey.now.sh/Icons/Clients/SIAC_LOGO.svg"> ...

Showing content in a way that spaces out below the text

Could someone assist me with a CSS problem I'm having? I understand CSS, but debugging is not my strong suit. When I use display: inline-block for both my Academic Information and Personal Information, I'm getting extra white space below (above " ...

Adjusting the size of tables in raw JavaScript without altering their positioning

I am attempting to adjust the size of a th element without impacting the position of the next th in the row. Specifically, I want the width of the th to influence the width of the next th accordingly, rather than pushing it to the left. Below is the code ...

White line appears in Chrome and Safari when using Bootstrap 4 image grid with rows

A grid has been created in Bootstrap 4 with the following structure: <div class="container-fluid"> <div class="row padding"> <div id="workshop1" class="col-lg-6 nopadding"> <img src="images/Werkstatt/image_05.jpg" class="i ...

Fixed Element Transitioning from Starting Position on Scroll

Check out the JSFiddle example here I'm currently working on a website utilizing Bootstrap 3. I have an image that sticks to the page when scrolling by changing its position to fixed. While this functionality works, the image tends to shift slightly ...

"The Fieldset Legend Mystery: Unraveling Internet Explorer's

I'm at my wit's end. Currently, I am customizing the front end of an ASP.NET built website, and one of the sections includes a fieldset with a legend. However, this specific area appears differently on IE, Firefox, and Chrome. Out of the three, ...

using javascript to dynamically color rows in a table based on the value in the status field

Hi, I'm new to javascript and seeking help for my table coloring issue. I have a dynamic table where data is inserted through an Ajax call. The goal is to color specific records based on their status. I attempted a solution but only one record gets c ...

How to disable scrolling for React components with CSS styling

When incorporating a React component into my HTML, I follow this pattern: <html> <body> <div id=app>${appHtml}</div> <script src="/bundle.js"></script> </body> </html> Within my application, th ...

enhance the brilliance of elements at different intervals

My latest CSS animation project involves creating a stunning 'shine' effect on elements with a specific class. The shine effect itself is flawless, but having all elements shine simultaneously is making it look somewhat artificial. I've bee ...

Adjusting the height of a jQuery Mobile collapsible post-expansion

My jQuery collapsible is not resizing properly to fit the expanded content. Below is an example of the collapsible structure: <div class="row collapsibles" data-role="collapsible"> <h1>Supercategory A</h1> <div class="col-xs-7 ...

Struggling with uploading files in AngularJS?

Below is the code snippet from my controller file where I aim to retrieve the values of various input elements (name, price, date, image) and store them in an array of objects... $scope.addBook = function(name, price, date, image) { name = $scope ...

How can I style the empty text in an ExtJS grid using CSS?

Is there a specific CSS class for a grid's emptyText? After inspecting the element with Firebug, all I found was: <div id="gridview-1021" class="x-component x-grid-view x-fit-item x-component-default x-unselectable" role="presentation" tabindex=" ...

Adjusting the transparency of TabBadge in Ionic 2

I am currently working on a project that involves tabs, and I'm looking to update the style of the badge when the value is 0. Unfortunately, I am unsure how to dynamically change the style of my tabs or adjust the opacity of the badge in the style. M ...

The panel's placement shifts when the browser window is expanded

Currently, the issue I am encountering involves an ASP.NET website with a header, sidebar, and additional right sidebar. When I resize the browser window, the left sidebar overlaps the content page, resulting in mixed-up controls. Please refer to the image ...

Is there a way to delay the start of this until a legitimate answer is provided in a pop-up window?

Is it possible to delay the loading of this content until a prompt box is answered with a valid response, and have it only appear once a month? Do I need anything beyond JS and HTML for this functionality? <script language="javascript"> function ...

A guide on accessing the href attribute of an HTML tag using jQuery

My goal is to extract the ID from the href attribute of an a tag on my webpage. First, I need to prevent the page from refreshing before performing this task. The example a tags look like this: '<a href="/ArtPlaces/Delete/5">Delete</a>&ap ...

HTML - various incorrect horizontal alignments

I'm having trouble getting the site logo, site name, and site header to align horizontally on my website. They keep ending up in different places.https://i.stack.imgur.com/5yL5f.jpg I'd like it to look similar to this: https://i.stack.imgur.com/ ...

td having no line breaks causing text to extend beyond the cell

I have a challenge with using the nowrap property on td elements to ensure proper formatting of my tables. In the first table, everything wraps nicely, but in the second table, the content in the first "td" exceeds its designated space due to length. How c ...

Showing a div element with the power of JavaScript

I want to enhance the accessibility of my website for users who do not have JavaScript enabled. Content that will be visible if the user has JavaScript enabled. Content visible when JavaScript is disabled. By default, DisableJS is set to Display:none; ...

Image showcasing the background

I'm facing an issue with adding a background image to my project Even after trying to add it globally, the background image is not showing up on the Next.js index page. import { Inter } from 'next/font/google' const inter = Inter({ subsets: ...