Troubleshooting extra whitespace issue while transforming Bootstrap Columns into a table layout with CSS

* {
  box-sizing: border-box;
}
.row-table {
  width: 100%;
  margin: 0!important;
  table-layout: fixed;
}
.row-t {
  display: table!important;
}
.row-tr {
  display: table-row!important;
}
[class*="col-"] {
  display: table-cell!important;
  padding-top: 15px;
  padding-bottom: 15px;
  border: 2px solid red;
  float: none!important;
}
.parent {
  border: 2px solid #000;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<br>
<div class="container-fluid">
  <div class="row row-table row-t parent">
    <div class="col-xs-6 col-sm-4 col-md-3">1</div>
    <div class="col-xs-6 col-sm-4 col-md-3">2</div>
    <div class="col-xs-6 col-sm-4 col-md-3">3</div>
    <div class="col-xs-6 col-sm-4 col-md-3">4</div>
  </div>
  <br>
  <br>
  <div class="row-t row-table parent">
    <div class="row row-tr">
      <div class="col-xs-6 col-sm-4 col-md-3">1</div>
      <div class="col-xs-6 col-sm-4 col-md-3">2</div>
      <div class="col-xs-6 col-sm-4 col-md-3">3</div>
      <div class="col-xs-6 col-sm-4 col-md-3">4</div>
    </div>
  </div>

</div>

Apologies for the slight alteration to this question in order to address an issue that was previously not being replicated.

I am aiming to achieve equal height for my bootstrap columns, mimicking tables and enabling vertical alignment at the center - this is my progress so far.

For a better experience, view these snippets in Full Screen mode - you may notice approximately 1px of whitespace on the left and right borders between the red and black sections. I aim to eliminate this gap, especially in Google Chrome. Any suggestions?

Additionally, please advise which approach would be more suitable for meeting these requirements.

Would the first approach be correct?

Where 'row' has display:table;

.row {
    display:table;
    margin:0;
    width:100%;
    table-layout:fixed;
}
.row >[class*="col-"] {
    display:table-cell;
    float:none;
}

Or perhaps the second approach is more appropriate?

Where 'row' has display:table-row;

.row {
    display:table-row;
    margin:0;
    width:100%;
    table-layout:fixed;
}
.row >[class*="col-"] {
    display:table-cell;
    float:none;
}

Answer №1

After some investigation, I have successfully identified the solution to this issue, which seems to be specific to Google Chrome. To resolve it, a minor workaround was required. I specifically added the CSS property border-collapse:collapse; to the parent element and removed its border properties.

* {
  box-sizing: border-box;
}
.row-table {
  width: 100%;
  margin: 0!important;
  table-layout: fixed;
  border-collapse: collapse;
}
.row-t {
  display: table!important;
}
.row-tr {
  display: table-row!important;
}
[class*="col-"] {
  display: table-cell!important;
  padding-top: 15px;
  padding-bottom: 15px;
  border: 2px solid red;
  float: none!important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<br>
<div class="container-fluid">
  <div class="row row-table row-t parent">
    <div class="col-xs-6 col-sm-4 col-md-3">1</div>
    <div class="col-xs-6 col-sm-4 col-md-3">2</div>
    <div class="col-xs-6 col-sm-4 col-md-3">3</div>
    <div class="col-xs-6 col-sm-4 col-md-3">4</div>
  </div>
  <br>
  <br>
  <div class="row-t row-table parent">
    <div class="row row-tr">
      <div class="col-xs-6 col-sm-4 col-md-3">1</div>
      <div class="col-xs-6 col-sm-4 col-md-3">2</div>
      <div class="col-xs-6 col-sm-4 col-md-3">3</div>
      <div class="col-xs-6 col-sm-4 col-md-3">4</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

Is background image alignment responsive?

Ensure to view it at 1680px width for perfect alignment, but resizing the screen may cause alignment issues. Any suggestions on how to resolve this problem? I am attempting to replicate my design from Dribbble shot. Snippet of code. .wrapper { pos ...

Tips on positioning divs in a vertical layout with CSS

I have a question about CSS. I have a simple footer with col-md-8 and col-md-4 classes. How can I arrange the col-md-8 above the col-md-4 at the media breakpoint of 720px (max)? I am new to CSS and would appreciate your help with this. Please run the snipp ...

Managing websites on Android when the keyboard is displayed

I am currently facing an issue with my webpage on Android (Galaxy SIII). The problem occurs when visitors try to enter their email in the form at the bottom of the page. The keyboard becomes visible, causing the design to look messy. When using Chrome, the ...

CSS: Card elevates when keyboard is activated on a mobile device

[view image 1[view image 2] Image 1: Normal View, Image 2: When the keyboard is enabled, the card jumps up and when I close it's normal. Is this behavior normal? Or is there a fault in my CSS? I utilized styled-components for writing the CSS. CSS ...

An issue has been encountered with the Array.insert function, as the Object function Array() does not contain the 'insert' method

Currently, I am utilizing javascript, HTML, and HTTPHandlers. In my code, there is a line in javascript that looks like this: Array.insert( Garray, eval(firstmarker), tmparray); Upon testing this line in the Google Chrome console, I encountered the follo ...

Chrome/IE displaying text indentation issue within nested divs

Encountering issues with nested divs in Chrome and IE, while Firefox works smoothly. The outer div has both text-indent and margin-top styles set. The inner div's display style is block, so the content after it should appear on a new line without any ...

I need either XPATH or CSS to target a specific checkbox within a list of checkboxes wrapped in span tags

I'm trying to find the XPATH or CSS locator for a checkbox in an HTML span tag that has a label with specific text, like "Allow gender mismatch". I can locate the label using XPATH, but I'm not sure how to target the input tag so I can click on t ...

display or conceal a div when a radio button is selected

I need a way to display a specific div containing unique text once a radio button is selected, while hiding all other div sections. <?php foreach ($items as $item){ $i=1; echo ' <div class="form-check"> <input class="fo ...

Locate a specific element by utilizing xpath

Recently, I encountered a coding issue that has been puzzling me. Here's the html snippet in question: <div class="Main"> <div> <div class="display">First:</div> <div class="price">$0.01</div> ...

Leveraging an array of Elasticsearch documents using AngularJS

The query results are given below... { "took": 6, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 45, "max_score": 0, "hits": [] }, "aggregations": { ...

Modify CSS in Angular Kendo Chart - Customize the style to display line when the value is equal to 0

Is there a way to customize the CSS style of the grid line when the value is zero on my chart? I'm looking to achieve something similar to this chart: https://i.sstatic.net/vf5wO.png ...

Remove the whitespace between the <h2> element and the CSS animation

Is there a way to remove the space between h2 and the animation in the following code snippet? .loader { border: 16px solid #f3f3f3; border-radius: 50%; border-top: 16px solid #3498db; width: 50px; height: 50px; -webkit-animation: spin 2s li ...

Scrolling a div automatically without affecting its parent element

On a page, I have a scrollable list of items that can be updated with a PUT request. Once the update is successful, another network request is made to fetch the updated list. The goal is to automatically highlight the recently updated item in the list. Al ...

Is it possible to include text in my numbered list?

My itinerary consists of the following ordered list: place1 place2 place3 Since this is for a trip plan, I would like it to appear as follows: Day 1: place1 Day 2: place2 Day 3: place3 I could manually type it out as plain text, but I am looking for ...

Issue with Fancybox Buttons not appearing on parent page upon opening

I previously asked for help on how to open fancybox from an iframe to the parent page. The solution worked perfectly and is still functioning well. Now, I've been requested to add left and right arrow buttons, but it seems that using the code to open ...

Issue with white spaces in footer content in Chrome browser

Currently in the process of developing a website and encountering a strange bug that only seems to be affecting Chrome. Despite having the latest version of Chrome, it appears to be an issue that was prevalent in older versions (v18 - v20). The problem is ...

Shifting annotations on a Bar Graph featuring Negative Values on Google's Chart Maker

Incorporating google charts into my MVC project. Looking to create a bar chart that accommodates negative values. Desire annotations on the same side as the end of the bar for negative values (similar to positive values shown in the green box below). ht ...

Expanding elements with Flexbox and Bootstrap 4: Strengthening the height to fill the remaining space

I have a row with three columns, each containing an image and a title. Currently, on a large screen, the titles are displayed on a single line and everything looks fine. However, when resizing the screen, the first title wraps onto two lines: My goal is ...

Bootstrap carousel slide animation isn't transitioning properly

I am encountering an issue with my carousel animation. I am aiming for a slide-out/slide-in effect similar to the Bootstrap website, but instead of sliding out, the old item simply disappears and the new item slides in. I have included a GIF to illustrat ...

Make sure that the equal sign is never utilized at the beginning of a form input field

Seeking a method to prevent the use of the "=" character in any input field within a form. <form> <input name="email" type="email" placeholder="Email" required=""> <input name="last name" type="text" placeholder="Last Name"> ...