Eliminating the gap between three HTML columns

I am facing an issue with reducing the space between 3 col-md-4 elements in my code. I attempted to decrease the margin between them while adjusting the padding on the first and last columns. However, this solution resulted in the image columns becoming misaligned when manipulating the window size due to the increased padding.

Here is the HTML:

<div class="cards">
  <div class="container">
    <h2>
      Our Expertise.
    </h2>
  </div>
  <div class="row">
    <div class="col-md-4">
     <!-- <img> -->
     <!-- <img> -->
     <!-- <img> -->
    </div>
    <div class="col-md-4">
     <!-- <img> -->
     <!-- <img> -->
     <!-- <img> -->
    </div>
    <div class="col-md-4">
     <!-- <img> -->
     <!-- <img> -->
     <!-- <img> -->
     <!-- <img> -->
    </div>
  </div>
</div>

And here is the CSS:

 html, body {
 margin: 0;
 padding: 0;
 font-family: 'Libre Baskerville', sans-serif;
 }

  .first    {
     padding-left: 200px !important;
  }

  .last {
    padding-right: 200px !important;
  }

  .container {
    max-width: 980px;
    margin: 0 auto;
  }

  .header   {
    padding-top: 20px;
  }

  .header h1    {
    font-size: 20px;
  }

  .nav li   {
    margin: 0px;
    border: 0px;
  }
  .nav li a {
    color: #333;
  }

  .jumbotron {
     background-color: transparent;
     padding-top: 100px;
     padding-bottom: 100px;

  }
  .jumbotron h2     {
     font-size: 50px;
  }
  .jumbotron h2 span    {
     color: #ffc200;
  }

  .banner {
     background-color: #333;
     height: 140px;
     color: white;
     text-align: center;
     padding-top: 30px;
  }

  .cards {
     background-color: #FFC200;
     text-align: center;
  }

  .cards img {
     margin-bottom: 25px;
     padding: auto;
  }

  .cards h2 {
     margin-top: 20px;
     margin-bottom: 80px; 
  }

  @media (max-width: 992px) {
     .col-md-4 {
     margin: 0 auto 0;
     text-align: center;
     width: 100%;
  }

  .cards img {
    width: 60%;
   } 
  }

@media (max-width: 500px) {
  .header h1 {
    text-align: center;
}

  .nav li {
    text-align: center;
    width: 100%;
}

  .cards img {
    width: 100%;
   }
 }

Unfortunately, I am unable to include images in the columns due to not having enough reputation points to post them.

Answer №1

To create equal spacing between columns, adjust the default column padding to maintain an even total space of 24. Simply change the default column padding from 15px to 12px, and make sure to override the negative margin on the row as well:

.row {
  margin-left: -12px!important;
  margin-right: -12px!important;
}

div[class*='col-'] {
  padding-left: 12px;
  padding-right: 12px;
}

.inner {
  border:1px solid black;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="cards">
  <div class="container">
    <h2>
      Our Expertise.
    </h2>
  </div>
  <div class="row">
    <div class="col-md-4">
     <div class="inner">Column 1</div>
    </div>
    <div class="col-md-4">
     <div class="inner">Column 2</div>
    </div>
    <div class="col-md-4">
     <div class="inner">Column 3</div>
    </div>
  </div>
</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

PHP and mysqli combine to create a versatile image slider with changing images

I am looking to implement an image slider that can be updated by the admin using php and mysqli. The admin should have the ability to easily add or remove images as needed. ...

Ensuring Safe Data Storage for an Angular 2 Project with Local Storage

One thing that worries me is the possibility of a hacker accessing the developer's console or local storage to alter user data, like the company name, and then gaining unauthorized access to my database. Here's a closer look at the issue: Curren ...

How can I reset an ng-model value of a range input in AngularJS?

Utilizing a filter with two inputs that share the same ng-model concurrently: <!-- Number input --> <input type="number" maxlength="5" step="0.25" min="-10" max="10" placeholder="0.00" ng-model="sphere"> <!-- Range Input --> <input ...

Processing PHP forms with dynamic form inputs

Have a form with the capability to add multiple input fields for ordering pictures by picture number. A customer could potentially order anywhere from 1 to 100 pictures. How should I handle this in PHP? Creating up to 100 $_POST[] variables for each poss ...

Embedding content within various ng-template elements

I'm currently working on developing a button component (app-button) that can utilize multiple templates based on the parent component using it. <div class="ds-u-margin-left--1 ds-u-float--left"> <ng-container *ngTemplateOutlet="icon">< ...

Struggles with aligning a hyperlink vertically in an unordered list

Here is a simple code I am using to vertically center a hyperlink within a UL. The style is applied to the hyperlink instead of the li because I need the entire list element to be clickable. Although my code works as intended, there seems to be a slight i ...

Validate User Input Using jQuery to Check if Empty or Deleted

Users can enter text into an input field, and an image will be displayed if the input is valid or invalid. I want to remove or change the image when the input field is empty. Despite writing the following code, it doesn't seem to work: $('#inpu ...

Issues with scrolling navigation have been identified in IE8

I am puzzled by the fact that the main navigation on this website is not functioning in IE8. redacted The code for the navigation is quite simple, with a localScroll feature attached to enable the scrolling effect. <ul> <li><a href=" ...

Press the HTML link to interact with a text using JAVA

I am currently working on creating a class that is able to interact with an A text/button in HTML. The webpage requires a username and password, so I have utilized JSOUP to parse the document and insert the user and password details using the .data method: ...

Having trouble with the WordPress style file not functioning properly

I'm currently facing an issue while trying to upload a CSS file and a JavaScript file to a custom theme on WordPress. When I open the webpage, nothing appears and there are no elements displayed. However, when I delete the functions.php file, the webp ...

Using the accordion class in Bootstrap 5 will disable the link functionality

When I click on a table row, it expands a hidden table row using the accordion classes. The clickable row also contains a link. In Bootstrap 4, the link was clickable but in Bootstrap 5, clicking the link triggers the accordion instead of following the lin ...

Troubleshooting problem with margin sizing in Material UI Autocomplete

My project is currently using Material-UI Autocomplete, and I've made modifications to ensure that the font and component resize appropriately when the viewport changes size. To achieve this, I used vw units for widths, heights, and font sizes. Howeve ...

What is the method for rearranging the order of Bootstrap 5 columns within nested elements without using hidden duplicates?

This snippet of code is designed to show blocks in different ways on mobile and desktop devices. <div class="col-12 col-sm-6 order-sm-1">TITLE</div> <div class="col-12 col-sm-6 order-sm-0">IMAGE</div> <div cla ...

PHP - Trouble with onClick event triggering "echo" to output Video and Image SRC using PHP tags

I am facing an issue with calling the data that I need to retrieve on a video src and image src. When I try to display them, they are not showing up. Can someone please provide me with the correct syntax? Thank you. I have a couple of questions, do I need ...

npm installs a multitude of dependencies

Recently, I purchased an HTML template that includes various plugins stored in a directory named bower_components, along with a package.js file. While trying to add a new package that caught my interest, I opted to utilize npm for the task. Upon entering ...

The submenu in Angular Bootstrap 3 navbar fails to trigger

I am currently using Angular 1.2.1 and Bootstrap 3.0.2. When I try to generate a menu using ng-repeat in my plain vanilla nav menu with a drop down, the submenu does not function as expected. Here is the HTML code: <ul class="nav navbar-n ...

Having trouble getting the CSS Hover state to function properly?

I am currently working with a code snippet that looks like this: <div style="position: absolute; margin-left: -22px; margin-top: -22px; left: 502px; top: 379px; z-index: 380; display: block;" class="maptimize_marker_0 f st">1<span class="pinlabel ...

Comparing identical elements in JavaScript

Crucial Note I want to clarify that I have no intentions of scamming, phishing, or causing any harm. My goal is to develop a website magnifier similar to using a magnifier on paper. Dilemma Let me paint the picture for you. I've effectively copied ...

Learn how to create text animations using CSS triggered by a scroll event listener

I'm looking to create a text animation similar to the one on this website: They have 3 keyframes for two types of animations: Left to Right and Right to Left. The RTL animation starts at 164vh, while LTR starts at -200vh. These text animations only ...

The puzzling case of the z-index in Bootstrap dropdown accordion arrangements

Currently, I'm encountering an issue with Bootstrap where placing a dropdown inside an accordion causes the dropdown menu of the first accordion header to be visually obstructed by the dropdown of the second accordion header when triggered. To better ...