Different Behaviours for Col-Lg

Different behaviours for col-lg

You can do same as you were doing earlier but need to download the bootstrap 4 sass file and reset lg grid breakpoint from _variables.scss file to 1080px like this

$grid-breakpoints: (
xs: 0,
sm: 576px,
md: 768px,
lg: 1080px,
xl: 1200px
) !default;

and recompile the entire source to get new custom bootstrap CSS file.
and use it like this.

<div class="catalogo">       
<div class="row">
<div class="col-12 col-md-6 col-lg-3 "> </div>
</div>
</div>

This is the file you need to change.
https://github.com/twbs/bootstrap/blob/v4-dev/scss/_variables.scss

But as a developer this is not recommended. But of course, it is possible if you deliberately want to achieve such kind of design.

Bootstrap 3 uses less preprocessor I believe it's variable.less contain @screen-sm: 768px; @screen-md: 992px;@screen-lg: 1200px; no xl so you can edit according to your need and recompile it. I think this should work.

What is the difference among col-lg-*, col-md-* and col-sm-* in Bootstrap?

Updated 2020...

Bootstrap 5

In Bootstrap 5 (alpha) there is a new -xxl- size:

col-* - 0 (xs)

col-sm-* - 576px

col-md-* - 768px

col-lg-* - 992px

col-xl-* - 1200px

col-xxl-* - 1400px

Bootstrap 5 Grid Demo



Bootstrap 4

In Bootstrap 4 there is a new -xl- size, see this demo. Also the -xs- infix has been removed, so smallest columns are simply col-1, col-2.. col-12, etc..

col-* - 0 (xs)

col-sm-* - 576px

col-md-* - 768px

col-lg-* - 992px

col-xl-* - 1200px

Bootstrap 4 Grid Demo

Additionally, Bootstrap 4 includes new auto-layout columns. These also have responsive breakpoints (col, col-sm, col-md, etc..), but don't have defined % widths. Therefore, the auto-layout columns fill equal width across the row.



Bootstrap 3

The Bootstrap 3 grid comes in 4 tiers (or "breakpoints")...

  • Extra small (for smartphones .col-xs-*)
  • Small (for tablets .col-sm-*)
  • Medium (for laptops .col-md-*)
  • Large (for laptops/desktops .col-lg-*).

These grid sizes enable you to control grid behavior on different widths. The different tiers are controlled by CSS media queries.

So in Bootstrap's 12-column grid...

col-sm-3 is 3 of 12 columns wide (25%) on a typical small device width (> 768 pixels)

col-md-3 is 3 of 12 columns wide (25%) on a typical medium device width (> 992 pixels)


The smaller tier (xs, sm or md) also defines the size for larger screen widths. So, for the same size column on all tiers, just set the width for the smallest viewport...

<div class="col-lg-3 col-md-3 col-sm-3">..</div> is the same as,

<div class="col-sm-3">..</div>

Larger tiers are implied. Because col-sm-3 means 3 units on sm-and-up, unless specifically overridden by a larger tier that uses a different size.

xs(default) > overridden by sm > overridden by md > overridden by lg


Combine the classes to use change column widths on different grid sizes. This creates a responsive layout.

<div class="col-md-3 col-sm-6">..</div>

The sm, md and lg grids will all "stack" vertically on screens/viewports less than 768 pixels. This is where the xs grid fits in. Columns that use the col-xs-* classes will not stack vertically, and continue to scale down on the smallest screens.

Resize your browser using this demo and you'll see the grid scaling effects.


This article explains more about how the Bootstrap grid

Understanding the grid classes ( col-sm-# and col-lg-# ) in Bootstrap 3

[UPDATE BELOW]

I took another look at the docs and it appears I overlooked a section which talks specifically about this.

The answers to my questions:

  1. Yes, they are meant to apply only to specific ranges, rather than everything above a certain width.

  2. Yes, the classes are meant to be combined.

  3. It appears that this is appropriate in certain cases but not others because the col-# classes are basically equivalent to col-xsm-# or, widths above 0px (all widths).

Other than reading the docs too quickly, I think I was confused because I came into Bootstrap 3 with a "Bootstrap 2 mentality". Specifically, I was using the (optional) responsive styles (bootstrap-responsive.css) in v2 and v3 is quite different (for the better IMO).

UPDATE for stable release:

This question was originally written when RC1 was out. They made some major changes in RC2 so for anyone reading this now, not everything mentioned above still applies.

As of when I'm currently writing this, the col-*-# classes DO seem to apply upwards. So for example, if you want an element to be 12 columns (full width) for phones, but two 6 columns (half page) for tablets and up, you would do something like this:

<div class="col-xs-12 col-sm-6"> ... //NO NEED FOR col-md-6 or col-lg-6

(They also added an additional xs break point after this question was written.)

What are the difference between col-lg and col-md in bootstrap3

When using Bootstrap those are the classes which are added for one column grid and correspond to extra small, small, medium and large devices.

.col-xs = *Extra small devices (ie Phones) (<768px)

.col-sm = Small devices (ie Tablets) (≥768px)

.col-md = Medium devices (ie laptops, or small desktops) (≥992px)

.col-lg = Large devices (ie Desktops) (≥1200px)*

This way through media queries you can allow to have only the right classes interpreted by the browser. If you surf that website from a tablet for example, you will see that the css properties which are actually applied in the browser are only the ones for the .col-sm class.

UPDATE

Also it's important to mention that those classes are used on a grid of 12 columns in total which is the grid system setup used by Bootstrap.

Therefore when you are using .col-sm-4 on an element it means that the element will take 4 columns out of 12 of the total width.
Which logically means that if .col-sm-4 is used then only 3 elements per row can fit into the page on tablet.

For example, let's say we want to show some project cards for a portfolio:

<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 card">
<div class="card-wrapper">
<img src="img.jpg">
<div class="overlay-text">
<h5>Project 1</h5>
<div class="labels">
<label>Tech Stack</label>
<h6>HTML5, CSS, JS</h6>
</div>
</div>
</div>
</div>

Using class="col-xs-12 col-sm-6 col-md-4 col-lg-3" all at the same time is used to activate different CSS properties on an element when viewing the page on a particular device.

In other terms, if the user opens the site on a desktop, col-lg-3 means that a total of 4 cards will be displayed, when col-md-4 means a total of 3 cards, col-sm-6 a total of 2 cards and then col-xs-12 means on mobile only 1 card will with 100% width of the page.

Unexpected behavior in div alignment in bootstrap grid layout

The problem is that your cols has different height so they stop in the first free space on the left.

You can force correct alignment using some empty rows between blocks.

check this pen:

http://codepen.io/anon/pen/GjWdKa

        <div class="row visible-sm visible-xs"></div>
<div class="col-lg-4 col-md-4 col-xs-6 block-ft">
<h2>Shopping with Us</h2>
...

For example in this case i force 'Shopping with Us' col to float in a new row for sm and xs size.

What is the difference between the **col-md-4** class and the **col-xs-4** class in BootStrap template?

Basically,

it will define the behavior of the columns in xl (extra large screens) and in md (medium screens);

Ex: when the screen is xl the columns will have the proportion where 12 is the sum of the columns, if the screen get smaller the columns will break. however, if you setup with md you can get the screen even smaller but the columns will no break until the dimensions:

  • xs (for phones)
  • sm (for tablets)
  • md (for desktops)
  • lg (for larger desktops)

reference:
https://getbootstrap.com/examples/grid/



Related Topics



Leave a reply



Submit