Enhance the grid system layout by inserting spaces between columns while maintaining the overall structure

I need to adjust the spacing between columns without disrupting the grid system layout. Adding margin to the cards results in only 3 cards per row instead of 4.

Below is the code snippet that I'm struggling with. The challenge lies in controlling the gaps between the cards while keeping each row at four cards.

 <div class ="container">
  <div class ="row">
    <div class ="d-flex flex-wrap">
        <div class ="card p-0 col-12 col-lg-3">
           <img src = "#">
           [Add your title here]<p> .... </p>
        </div>
         <div class ="card p-0 col-12 col-lg-3">
           <img src = "#">
           <p> .... </p>
        </div>
        <div class ="card p-0 col-12 col-lg-3">
           <img src = "#">
           <p> .... </p>
        </div>
        <div class ="card p-0 col-12 col-lg-3">
           <img src = "#">
           <p> .... </p>
        </div>
    </div>
  </div>
 </div>

<style>
.card img{
width:100%;
}
..card p{
width:100%;
color : green;
font-size :18px;
float:right
}
</style>

Answer №1

Previous queries with similar questions have been raised:

Adjusting spacing and column sizes using Bootstrap 4
Bootstrap: Adding margin/padding space between columns in Bootstrap

To change the spacing, modify the padding accordingly. Remember to place the card within the columns, which should always be inside a row. In this example, using px-4 increases the spacing:

<div class="row">  
    <div class="col-12 col-lg-3">
        <div class="card">
            <img src="#"> [Insert title here]<p> .... </p>
        </div>
    </div>
    <div class="px-4 col-12 col-lg-3">
        <div class="card">
            <img src="#">
            <p> .... </p>
        </div>
    </div>
    <div class="px-4 col-12 col-lg-3">
        <div class="card">
            <img src="#">
            <p> .... </p>
        </div>
    </div>
    <div class="col-12 col-lg-3">
        <div class="card">
            <img src="#">
            <p> .... </p>
        </div>
    </div>
</div>

View Demo

Answer №2

Without access to your complete CSS code, it's difficult to say for certain, but you may want to consider implementing grid-row-gap and grid-column-gap to control the spacing between rows and columns in your grid layout. Additionally, using grid-template-columns will allow you to specify the number of columns you desire.

I hope this information proves helpful! Best regards, Tilier

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

The POST Method encountering issues within the <code> tag

<form name="submit_form" action="./uploads/submit.inc.php" method="POST"> <div class="wrapper"> <code id="ace-editorid" name="code_editor">Input Your Code Here</code> </div> <script sr ...

Issue with displaying the second dropdown based on the selection made in the previous dropdown

I wanted to address a recurring issue that has been discussed in various posts, such as this one on Stack Overflow: Show a second dropdown based on previous dropdown selection Despite attempting numerous solutions suggested in those posts, I have not been ...

Tips for designing posts within a Bootstrap card column

I have a code snippet for displaying posts in a bootstrap card column layout. %h4{:align => "center"} All Posts %hr.my-3 - @posts.each do |post| %h4= link_to post.title, post %p= post.description %p= post.company I am looking to display the firs ...

CSS elements unexpectedly remain in line

I have encountered an issue with a navigation bar on one of my website projects. The HTML elements I am trying to add afterwards are not aligning properly with the navbar. I have thoroughly checked for any open HTML tags, syntax errors, or conflicting CSS ...

Customizing the scroll bar appearance in Internet Explorer using CSS styles

Encountered an issue with the scroll bar on iPad and browsers. The style is working well with Opera, Safari, Firefox, and Chrome, but it doesn't display properly in Internet Explorer, appearing a strange horizontal scroll bar on the page as well. You ...

Managing data from POST requests in Angular using Typescript

I have implemented a simple function in my component TypeScript file to send a post request and retrieve data from a server. The function is working correctly, but I am facing an issue when trying to assign the array of data to a variable named 'json& ...

Updating user schema in Angular to include question_id in list of bookmarks

Schema: var UserSchema = new Schema({ ques_bookmarks: [{ type: String }], }) Controller: .controller('questionsController', function(questionsFactory, $routeParams, $scope) { var that = this; questionid = $routeParams.id; stats = fal ...

The CSS and JavaScript in pure form are not functioning properly upon deployment in Django

In my Django project, I am utilizing pure CSS and Bootstrap. Everything appears as expected when I test it on my local machine. However, once deployed, the appearance changes. The font looks different from how it did before deployment: After deploying to ...

The Bootstrap menu seamlessly extends beyond the edge of the screen

Whenever I try to zoom in on my page, the navigation bar doesn't collapse as expected. Instead, it overflows off the page. This issue persists when viewing the website on mobile devices in landscape mode. Although I am using the jQuery mmenu plugin, ...

The changes made in the CSS file are not reflected in the browser

Recently, I encountered a strange issue with my new server where the CSS changes were not reflecting in the browser. Despite trying to refresh and clear the cache, the problem persisted. To investigate further, I used FileZilla to check if the updated CSS ...

Issue with Bootstrap tool tip not functioning inside modal form label tag

Is it possible to have a hover-over tooltip associated with text inside a label tag? I seem to be having issues with this implementation. When I move the tooltip outside of the label, it works fine. Below is the code snippet in question: <div class=&quo ...

unusual occurrences with CSS and JavaScript when hovering over TEXTAREA or A elements

Lately, I've been facing an unusual issue in my web application (php) that was fine just a month ago. Upon hovering over a specific < TEXTAREA > or two buttons (add, exit) within a DIV, the background color of the DIV fills up, rendering the IN ...

Remove bulleted list from HTML using JavaScript DOM

My task involved deleting the entire "agent" array using the removeChild() function, requiring the id of a <ul> element. However, I faced an issue as I couldn't set the id for the "ul" due to using the createElement() function. //old code < ...

Is there a way to choose a div in Jsoup that lacks an id or any attributes?

I am facing a challenge where I have to choose a specific div using Jsoup. Traditionally, divs can be selected based on their id or class attributes using getElementById() for IDs and getElementsByClass() for classes. However, the div that I need to select ...

What is the best way to trigger a new css animation on an element that is already in the midst of

Let's talk about an element that already has an animation set to trigger at a specific time: .element { width: 100%; height: 87.5%; background: #DDD; position: absolute; top: 12.5%; left: 0%; -webkit-animation: load 0.5s ease-out 5s bac ...

What is the method for adding <option> tags to a <select> statement using a for loop?

Currently, I am facing a challenge in dynamically populating the <option> tags within a <select> menu. My approach involves using a for loop in JavaScript to cycle through the number of options and append them to the select tag. The part of th ...

Guide on utilizing `ReactCSSTransitionGroup` for developing an expandable/collapsible list

Utilizing ReactJS to implement a collapsible/expandable list with animation has been my latest endeavor. To access the code, simply visit this link. Upon clicking the Extend button located at the top of the list, I anticipate the items to appear within 1 s ...

How to enable the Copy to Clipboard feature for multiple buttons and transition from using an ID to a class identifier

Can someone please assist me? I have a copy to clipboard function that works well for IDs and a single button on my website. However, I need to modify it to work for multiple buttons and values with a class identifier. Unfortunately, I am unsure how to mak ...

What could be the source of this margin or spacing?

Within this test, I have noticed that there are 2 inline flex containers. Specifically, I am referring to the test scenario that states Next The flex containers are laid out inline. Despite the fact that there is some space between the containers, upon in ...

the text-align center property does not function properly in a list

I am trying to center my unordered list (<ul>), but the layout is not as expected. This is my CSS code: .sub_menu { background-image: url("../images/background_sub_navi.png"); background-position: center center; height: 44px; } .sub_me ...