In the Bootstrap documentation itself there is a comparative table between the grid classes.
That is, the class .col-xs-*
define the grid for devices with a screen width less than 768px. The class .col-sm-*
sets for screens higher than 768px. The class .col-md-*
sets for screens higher than 970px and class .col-lg-*
for screens higher than 1200px. Its use is basically to define different grids for your element, based on the size of the display of your user.
For example, you might want to display a sector of your site in two columns on monitors by setting the class .col-sm-6
for each. However, on small screen devices such as mobile, two columns may not be ideal, leaving content squeezed and small, with this you can define that on these devices, instead of two columns, this sector is in only one column, with the class .col-xs-12
.
Basically you’re telling the browser: if the user screen has a width greater than or equal to 768px, display this div
occupying 6 of the 12 columns of my grid. Already, if the width is less than 768px, display it occupying 12 of the 12 columns of the grid.
<div class="col-xs-12 col-sm-6">...</div>
It is a very useful feature especially when you have, for example, a list of products in a virtual store. You can define how many products appear per line in each display setting the column size.
<div class="col-xs-12 col-sm-4 col-md-3 col-lg-2">{Produto}</div>
Thus, would appear 1 product for extra small Devices, occupying 12 of 12 grid columns, 3 products in small Devices, occupying 4 of 12 columns, 4 products in medium Devices, occupying 3 of 12 columns and 6 products in large Devices, occupying 2 of 12 columns.
Personal note: The grid system is, as presented, the main functionality of Bootstrap implementing the philosophy Mobile First and responsiveness. If you have been using it for a long time and did not know this difference, I recommend studying the documentation a little more before continuing or seeking another method of study. (Take this as a positive review)
take a look at the explanation of w3cschools, there are examples and Try it yourself.
– Darleison Rodrigues