Exploring Bootstrap 4 Grid - Understanding the Difference Between .col-breakpoint and .col-number

I've recently decided to make the move from Bootstrap 3 to Bootstrap 4 and I'm taking a closer look at the changes in the grid system.

https://getbootstrap.com/docs/4.0/layout/grid/

It explains:

  • Thanks to flexbox, grid columns without a specified width will automatically layout as equal width columns. For instance, four instances of .col-sm will each automatically be 25% wide from the small breakpoint and up.

  • Column classes indicate the number of columns you’d like to use out of the possible 12 per row. Therefore, if you want three equivalent-width columns across, you can utilize .col-4.

Given this information, what would be the distinction between using:

  1. Four instances of .col-sm
  2. Four instances of .col-3

Both options would occupy 25% width of a .row. Am I correct?

So, what is the difference between specifying it either way?

In Bootstrap 3, you were required to use specific numbers within a 12 column grid, for example, using 4 instances of .col-sm-3 meant you would have 4 (25% width) columns since 12/3 = 4

Answer №1

"Given this scenario, how would using the following differ:"

  • Utilizing four instances of .col-sm
  • Employing four instances of .col-3

While they may seem similar in some cases, it's important to note that col-3 will not stack vertically as it only applies to the smallest (xs) breakpoint. On the other hand, col-md will stack vertically for medium size screens with a viewport smaller than 768px.

Explore this example on Codeply

If you are working with 4 columns, remember that col-3 will always be set at 25% width. In contrast, col-md will distribute the width equally regardless of the number of columns.


For more information, check out: Understanding the Difference Between col-lg-*, col-md-* and col-sm-* in Bootstrap

Answer №2

The Bootstrap 3 grid system originally included 4 breakpoints:

Extra small (for smartphones with classes like .col-xs-*)

Small (for tablets with classes like .col-sm-*)

Medium (for laptops with classes like .col-md-*)

Larger (for desktops and larger laptops with classes like .col-lg-*).


In the latest version, Bootstrap 4, a new breakpoint called -xl- has been added. Additionally, the -xs- infix has been removed so the smallest columns are now simply col-1, col-2... col-12, etc.

col-* denotes 0 for extra small screens

col-sm-* starts at 576px

col-md-* starts at 768px

col-lg-* starts at 992px

col-xl-* starts at 1200px

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

Unexpected issue with sliding menu toggle implementation

I have been struggling to make a menu slide to the left when a button is clicked, and then slide back to its original position when the same button is clicked again. Although I have been using the toggle method, it doesn't seem to be working for me. I ...

How to vertically center images in Bootstrap Carousel using the img-fluid class

I'm attempting to center both horizontally and vertically the images in the bootstrap carousel using the img-fluid class. I want the images to be fully visible (100%) and adaptable to different screens, so I've been utilizing the img-fluid class. ...

How can screen readers be alerted about freshly loaded content through ajax?

Whenever a user clicks on a button, I want to add more content to the page. The new content will be visually clear, but how can I ensure that screen readers can easily access it? I've come across two best practices that suggest additional steps may b ...

I successfully created a Chinese writing practice deck in Anki, which is functional on the desktop version but unfortunately not compatible with Ankidroid

While AnkiDesktop is functioning properly, there seems to be an issue with character encoding in Ankidroid. Despite trying numerous solutions, the problem persists. The character length displays correctly in Anki Desktop, but not in Ankidroid. For example ...

A design with three columns that stretch to 100% height using CSS styling

I can't seem to figure out the CSS for this layout. Here is the HTML code I have: <body> <div id="main"> <div id="left"> menu </div> <div id="middle"> </div> ...

PHP cannot render CSS properly

I recently discovered a clever technique for equally spacing divs within a container, thanks to this helpful tip: Fluid width with equally spaced DIVs I decided to test it out using static HTML and everything worked perfectly: <div class="category_are ...

Adding Bootstrap to your Angular project with ng cli

I recently created a new Angular 2 project using the "ng cli" command. I have also installed Bootstrap using npm. Now, my question is how can I correctly add Bootstrap, which is located in the npm packages folder, to my Angular project so that the CSS and ...

How can you iterate over the input elements that are currently visible within a form using Javascript?

Is there a way to clear the values of all visible input fields in a form using JavaScript? I'm currently struggling with setting text inputs to empty as they come out as undefined. Any suggestions on how to achieve this? ...

Variables are losing their way in the vast expanse of self-submitting

I have a form that needs to be submitted on the same page (index.php) and I want to capture the entered information as a JavaScript variable. <?php $loginid = $_POST[username] . $_POST[password]; ?> Here is some basic code: <script> var pass ...

I have a `null` input value. Is there a way to compute this value in relation to a date

When the input is null, what can be done to calculate the value with date? https://i.stack.imgur.com/DmFsJ.png /* // ======================================================== * * * * * How To Calculate Input Value With Date When Input Is Null * * */ // ...

Display or hide a div element when hovering over it, while also being able to select the text within

I am trying to display and conceal a tooltip when hovering over an anchor. However, I want the tooltip to remain visible as long as my cursor is on it. Here is the fiddle link $('#showReasonTip').mouseover(function(){ $(this).parent().find(&apo ...

modify style when not valid and is touched

When I try to modify the style of an i tag based on the touched and invalid state of another field, only the input tag's style changes and not the i tag. Here's the CSS code I'm using: input.ng-touched.ng-invalid { border-color: red; } ...

How can I create a Bootstrap button with a custom href link in my code

I have created a button, is it possible to add an "href" link to this code? My link isn't working! <button class="buttoncostum"> <a href="http://example.com/"><span class="glyphicon glyphicon-th-list" style="color:white" aria-hidden=" ...

Move images horizontally next to the height of an element

I am attempting to increase the top attribute in relation to the element it is currently adjacent to. The element should only scroll directly next to the other element and cease when it surpasses the height of that element. My Goal: I want the image to re ...

Using Bootstrap svg link in background-image not functioning correctly for radio buttons, checkboxes, and various other icons

I decided to give my Bootstrap design a personal touch by customizing it with my own styles. To do this, I copied an HTML page containing all the Bootstrap elements from bootswatch.com/default. After adjusting the directories in the "link" and "script" tag ...

Utilize the dimensions of one image to resize others using the JavaScript method .getBoundingClientRect

I am attempting to transfer the width and height measurements of the initial image to all subsequent images on the page. Currently, I have successfully applied the dimensions of the first image to the second one, but I am facing difficulties with the thir ...

HTML Email Clickable Box

I am very new to this platform and I feel like I am overlooking something obvious. What I want is an HTML button that will open the user's native email client with the To: field already filled in. <form> <button class="button-21" ...

The content in an app using Ionic and Angular is being obstructed by the bottom tabs, preventing users

I am facing an issue with my Ionic and Angular app. When I place tabs at the bottom of my page, outside the ion-content, the scrolling stops working inside the ion-content and the fab button, which is located inside the ion-content, ends up covering the ta ...

Can microdata be applied to an element that embodies a pair of data points?

Can itemprop="name" and itemprop="contentURL" be included in the same element? For example: echo '<li itemscope itemtype="http://schema.org/AudioObject">'; echo ' <a itemprop="name" itemprop="contentURL" href="http://wav ...

Interested in providing placeholder with 2 distinct colors?

Is it possible to change the color of a placeholder text to two different colors? Let's take a look at the code: <input type="text" class="form-control setting-form" id="inputDefault2" placeholder="http://blabbr.im/#itsmyne ...