Tips for populating a row in the Bootstrap grid with the assistance of the mr or ml classes

I've come across a roadblock here.

The issue arises when attempting to fill the Bootstrap row while also utilizing mr (or ml). Initially, I attempted to calculate the numbers so that they add up to 12. In my 3-column layout, I have a column of 5, followed by a column of 4, leaving 3 remaining columns, right?

However, everything functions as expected until I introduce mr (margin-right) between the boxes/columns, causing all my boxes (columns) to stick together. Upon adding mr (greater than 0), the 3rd column is pushed below.

While I understand the problem, I'm unsure of how to navigate around it.

I "resolved" this by assigning the 3rd column a col-xl-2 width, but then it fails to fill up the space at the end of the row. I thought col-lg-auto would fix this issue, but in reality, it makes the column even narrower. Manipulating column widths and similar aspects doesn't seem to be the solution as it compromises the page's responsiveness. So, what is the correct approach?

This seems to be an ongoing issue – as the resolution decreases and the 3rd column is automatically pushed down, the 2nd column fails to occupy the entire space of the first row again.

Here is my code snippet:

<div class="row row-center">

<div class="col- col-sm-12 col-md-12 col-lg-7 col-xl-5 col-center mr-3 p-0">

    <div class="tile-first-row-text">
      Latest Events
    </div>


</div>
<div class="col- col-sm-12 col-md-12 col-lg-4 col-xl-4 col-center mr-3 p-0">

    <div class="tile-first-row-text">
      Table
    </div>


</div>
<div class="col- col-sm-12 col-md-12 col-lg-12 col-xl-2 col-center p-0">
  <div class="tile-first-row-text">
    Prediction Cup
  </div>
</div>

Answer №1

The concept of grid systems involves dividing the width into 12 parts. When margins are added to these parts, additional pixels are created.

For example, if the size is 1200px using a grid system, you may have divided it into columns of 500px, 400px, and 300px. Adding margin between these columns consumes some of the width, causing the third column to lack sufficient space in that row and pushing it to the next row.

If you want space between your columns, consider using padding instead of margin as it won't affect the overall width distribution. I hope this addresses your query correctly.

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 completely eliminate a div from a webpage

I've created a new div element using jQuery: $(document.body).append('<div id="test"></div>'); Then, I display a success message and remove the div after 10 seconds: $('test').html('SUCCESS!'); setT ...

Hiding a div by setting its display property to none using a button press

I have been having difficulty finding a solution to my problem despite trying multiple topics. My English skills are not the best, but I hope to explain my issue as clearly as possible. After clicking on this div, I would like to block the display and sho ...

Restoring text boxes to their original styling

I've been working on a jQuery script that scans through form input elements and turns their border color to red if they are empty. When the submit button is pressed, it reassesses the elements; this time I'm trying to revert the textbox back to i ...

MacOS web browsers adjust content to fit the screen size

As I delve into React development, one thing that has caught my attention is how MacOS browsers try to fit all the page content in view rather than allowing users to scroll. Let me illustrate this with an example: function Example() { const Elements = ...

Steps for resetting a div's display after adjusting the device size

I have a code that displays horizontally on desktop screens and vertically on phones. It includes an x button (closebtn) that is only displayed on phones to close the menu bar. How can I automatically display it again after resizing the page back to deskto ...

Triggering jQuery events can be customized by excluding certain elements using the

Is there a way to hide the div "popu" when clicking on the img "tri"? I've tried using .not() since the img is a child of the div popu, but it didn't work. Also, I need to make sure that clicking on the div "textb" does not trigger the hide actio ...

Ways to avoid the cascading of CSS styles onto multiple Three.JS scenes

It seems like I might have to take the longer route to solve this issue, but let's give it a shot... I'm facing a challenge when applying CSS to control the opacity of a specific HTML element that acts as a container for a Three.JS scene. In thi ...

The pseudo right arrow is failing to display in the vertical center

My pseudo right arrow is not displaying vertically centered within the .nav-link class. Can anyone suggest how I can achieve vertical alignment for my right arrow in an <a> tag? I have already attempted using top:50% but it did not work. Here is th ...

What steps can I take to improve the design of this layout created using Twitter Bootstrap?

Currently, I am designing a sample form layout using Twitter Bootstrap. The form displays fields horizontally, with a link between each field. My goal is to have bullet points appear on the right side of the fields when the link is clicked. However, the al ...

Manipulate the CSS of a single div within a group of divs that have the same class using jQuery

I'm attempting to modify the CSS of a specific DIV that shares its class with other divs. I've searched for a solution but haven't had any luck so far. Here is the code I've been using without success: $(".singleOffer").click(functio ...

Leveraging the power of jQuery and vanilla JavaScript to create a pop-up print window for a Div element within a CMS platform that does not support media query stylesheets

I have been grappling with this particular issue for weeks now, seeking guidance from previous inquiries here. Yet, despite the helpful hints, I am still struggling to find a viable solution. My website features a scrolling sidebar measuring approximately ...

When a textarea contains a new line, it will automatically add an additional row and expand the size of the textarea

Developed a form with the functionality to move placeholders in a textarea upwards when clicked. The goal is to increment the height of the textarea by 1 row for every line break. However, I am uncertain about what to include in the if statement of my Ja ...

The function assigned to [variable].onclick is not being executed, despite no errors being displayed in the console

I'm new to javascript and I'm looking for help with a simple task. I want to create a code that when clicking on an image, it will open in a modal. This feature is important for viewing full-size images on my portfolio. Although there are no erro ...

Display of certain special characters such as ">" may be affected when using UTF-8 encoding

Here are the codes I'm working with: ul.pathnav a:before{ content:"\0X3E"; text-decoration:none; } I have been trying to use the hex code \0x3e for ">", but it doesn't seem to be working. However, when I tried usi ...

The "read more" button seems to be malfunctioning

I've been working on integrating a gallery of images into my posts. My goal is to display 4 images initially, followed by a "load more" button that, when clicked, will reveal another set of 4 images, and so on. I have already created the HTML, CSS, an ...

The pagination styles in Bootstrap are refusing to be overwritten by custom CSS variables

Incorporating Bootstrap version 5.3.3, I have implemented a customized WordPress theme where I have specified a range of color overrides. The custom WordPress theme stylesheet is loaded last, following the Bootstrap stylesheet. At the beginning of my the ...

Is it possible to shift the "ul" block of the navigation bar to the right without compromising the responsiveness toggle button functionality?

I'm currently using bootstrap NavBar and encountering an issue where moving the ul block to the right is disabling the toggle button responsiveness. <head> <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" c ...

`the mobile site is not displaying properly on the screen`

I'm struggling to make my website responsive on mobile devices. I'm using Bootstrap, but when viewed on a mobile device, it's not adjusting the layout properly. Other sites I've worked on automatically zoom in to display correctly on mo ...

The code functions perfectly on JSfiddle, but for some reason it halts when implemented on

Unfortunately, the code that was working perfectly on JSfiddle seems to be encountering issues when implemented on a regular HTML site. The content loads fine but there seems to be an error with the preview function after selecting an image. We have colla ...

Navigating through pages in React using Pagination Animations

Attempting to style an active button with a small transition when it receives that attribute has been a challenge. The same issue occurs with the paragraph rendered from the data file. function Pagination() { const [selected, setSelected] = useState(0) ...