Difficulty in centering two equal-sized columns in a Bootstrap 3 row with an offset

Here is a link to my demonstration on JSFiddle: https://jsfiddle.net/nbd2w3zb/

I am working with Bootstrap 3 and have created 2 equal-sized columns (.col-md-4) within a .row.

The desired effect is to center both of these columns inside the .row, ensuring there is an equal amount of space on each side - to the left of "Column A" and to the right of "Column B".

In addition, it's important that there is some space between "Column A" and "Column B", as illustrated in the screenshot - I do not want the borders to touch.

Despite trying to use offsets, I am unable to achieve this desired result. No matter what adjustments I make, the spacing remains uneven and the columns are off-center. Here's how it looks currently: https://i.sstatic.net/1RXue.png

I have come across a suggestion in a post on Stack Overflow (Bootstrap: two column centered) where the accepted answer involves inserting empty div tags to add up to 12 columns. However, this approach does not seem ideal to me. Another solution mentioned using offsets, but I have struggled to make it work regardless of which numbers I try.

I believe that achieving this alignment should be possible in Bootstrap. Can anyone point out where I might be making a mistake?

Answer №1

Adjust the first column by an offset of 1 and the second by an offset of 2. This results in a total of 1 + 4 + 2 + 4 = 11, leaving one on the right side to make it 12. Check out the DEMO for further details.

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

Issue with iPhone CSS displaying differently on mobile devices

The CSS design does not display correctly on iPhone devices in real-life testing, even though it appears fine on browsers with mobile view emulators. Interestingly, the design also looks great on Android phones but encounters issues specifically on iPhones ...

Adding Tooltips to Your Bootstrap 5 Floating Labels Form: A Step-by-Step Guide

Can you include tooltips or popovers in Bootstrap 5 floating labels text? I've set up a form with floating form fields and I'd like to provide instructions for certain fields using tooltips or popovers. I can make it work with the standard form ...

Declare a jQuery variable containing HTML elements

Greetings! I am facing an issue while attempting to create a jQuery variable that stores a table meant for displaying in different sections of a website. Unfortunately, I am encountering an error and struggling to comprehend the reason behind it. Below is ...

"Step-by-step guide on creating a dynamic clipping mask animation triggered by mouse wheel

I have developed a sample that functions just as I envision my final outcome to function, with the exception of triggering on mouse-over. Instead, I would like it to activate as a page transition when scrolling with the mouse. (move your cursor over the i ...

Implementing Angular with HTML progress bar for interactive client-side features

Exploring the integration of HTML built-in progress bars with Angular: <label for="file">File progress:</label> <progress id="file" max="100" value="70">30%</progress> I am curious about how ...

Using jQuery to toggle sliding the information above a div

I am facing an issue with my customized sliding menu. The menu slides over the image but not over the content-div, pushing it aside. I have tried to fix this problem but haven't found a solution yet. My goal is for the menu to slide over all divs and ...

Exploring robot framework methods for class verification

Are there any specific keywords in Robot Framework that can be used to verify if an element has a particular class assigned to it? Perhaps something like Element should have class element className Or I could also check if the element has a specifi ...

Guide on utilizing the carousel component in Bootstrap and populating it with data generated from Node.js

My goal is to design a carousel that displays 5 different pieces of information pulled from a separate app.js file. I attempted to implement a forEach loop, but encountered issues when trying to create a second Bootstrap carousel container. Here's th ...

What causes the bootstrap grid system to deviate from the intended column sizes?

Here is the alignment I am aiming for with the Phone and Extension fields in the form: https://i.sstatic.net/JRmDU.png This is the code snippet I have written for the Phone and Extension row: <div class="row form-group"> ...

Create original identifiers for dynamically generated material

I have developed a custom invoice tool that has the capability to dynamically add rows. Here is the code snippet responsible for generating new rows: $("#addrow").click(function(){ $(".item-row:last").after('<tr class="item-row"><td> ...

CSS: dynamic font-size based on text length

Can the font size be adjusted based on the length of the text without using JavaScript? I have a box with a width and height of 140px. The content inside should be 100px wide and high (with a 20px padding). The text should utilize this 100px width effecti ...

Instructions on how to position the footer below the content and make it show inline

This question seems to be a duplicate, with only one unanswered answer and no discussion. The original poster did not confirm if the solution worked. I have tried the suggested CSS but it does not solve my problem, which I believe is the same. My layout i ...

Struggling with dynamically updating fields based on user input in real time

I have a goal to update a field based on the inputs of two other fields. Currently, all the fields are manual input. Below is the code I'm using to try and make the "passThru" field update in real-time as data is entered into the other fields. The ma ...

Whenever I click the left mouse button, the website crashes

Why does clicking the left mouse button make the website scroll down? Any ideas for a solution? Check out the link here: I've tried everything since I just started working on my website. Be prepared to be shocked when you see the source code HAHAHHA ...

Update the src path for the backgroundImage in ReactJS to pull from a directory within the CSS

I'm currently working on changing the ImageBackground for a Material-UI Button Image component. The challenge I'm facing is that the CSS configuration requires a backgroundImage property, but it searches through the URL browser instead of my loca ...

Determine the outcome with a PHP conditional statement for either "

I'm currently working on adding a function to a script where the user is prompted for a code, which I have successfully added. However, I am facing an issue in determining when to ask the user for the code and when not to. So, I believe I need to use ...

Is it possible to adjust the CSS code linked to the HTML tag based on the specific webpage being viewed?

I am facing an issue with the homepage of my website, which uses Scrollmagic.js for smooth scrolling. In order for the sticky footer CSS to work properly on all other pages, the HTML tag needs to have a height of 100%. However, if I add this height value t ...

The height of the absolute div tag does not match the height of the parent div

I am currently designing an editor that requires a line-number bar (gutter) on the left side. I have set a div with a height of 100% and its parent div with overflow: auto. My expectation is that if the content exceeds the given height, the editor-body sh ...

The Colorful World of CSS Backgrounds

I've been searching for hours trying to track down the source of this strange greenish background color. I've combed through every single file and it's starting to drive me insane. Any ideas where this color could be coming from? I highly d ...

Including content without triggering the digest cycle (utilizing raw HTML) within a Directive

My goal is to include raw HTML inside a directive for later transclusion (to populate a modal when opened). The issue arises when the contents of dialog-body are executed, triggering the ng-repeat loop and causing the template to be rerun, leading to a po ...