本文翻译自:What is the difference among col-lg-*, col-md-* and col-sm-* in Bootstrap?

Twitter Bootstrap中的col-lg-*col-md-*col-sm-* col-md-*什么区别?


#1楼

参考:https://stackoom.com/question/1LLpm/Bootstrap中的col-lg-col-md-和col-sm-有什么区别


#2楼

From Twitter Bootstrap documentation : 从Twitter Bootstrap文档中 :

  • small grid (≥ 768px) = .col-sm-* , 小网格(≥768px)= .col-sm-*
  • medium grid (≥ 992px) = .col-md-* , 中格(≥992px)= .col-md-*
  • large grid (≥ 1200px) = .col-lg-* . 大网格(≥1200px)= .col-lg-*

#3楼

Updated 2019... 2019年更新...

The Bootstrap 3 grid comes in 4 tiers (or "breakpoints")... Bootstrap 3网格分为4层(或“断点”)...

  • Extra small (for smartphones .col-xs-* ) 特小(适用于智能手机.col-xs-*
  • Small (for tablets .col-sm-* ) 小(适用于平板电脑.col-sm-*
  • Medium (for laptops .col-md-* ) 中(适用于笔记本电脑.col-md-*
  • Large (for laptops/desktops .col-lg-* ). 大(适用于笔记本电脑/台式机.col-lg-* )。

These grid sizes enable you to control grid behavior on different widths. 这些网格大小使您可以控制不同宽度上的网格行为。 The different tiers are controlled by CSS media queries . 不同的层由CSS 媒体查询控制。

So in Bootstrap's 12-column grid... 因此,在Bootstrap的12列网格中...

col-sm-3 is 3 of 12 columns wide (25%) on a typical small device width (> 768 pixels) 在典型的小型设备宽度(> 768像素)上, col-sm-3是12列宽(25%)中的3列

col-md-3 is 3 of 12 columns wide (25%) on a typical medium device width (> 992 pixels) col-md-3在典型的中等设备宽度(> 992像素)上为12列宽(25%)中的3列


The smaller tier ( xs , sm or md ) also defines the size for larger screen widths . 较小的层( xssmmd )还定义了较大屏幕宽度的大小 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-lg-3 col-md-3 col-sm-3">..</div>

<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. 因为col-sm-3 3 units on sm-and-up意味着3 units on sm-and-up ,除非被使用不同大小的较大层特别覆盖。

xs (default) > overridden by sm > overridden by md > overridden by lg xs (默认值)>被sm覆盖>被md覆盖>被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. smmdlg网格都将在小于768像素的屏幕/视口上垂直“堆叠”。 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. 这就是xs网格所在的地方。使用col-xs-*类的col-xs-*不会垂直堆叠,并且会继续在最小的屏幕上按比例缩小。

Resize your browser using this demo and you'll see the grid scaling effects. 使用此演示调整浏览器的大小,您将看到网格缩放效果。


Bootstrap 4 引导程序4

In Bootstrap 4 there is a new -xl- size, see this demo . Bootstrap 4中有一个新的-xl-大小,请参阅此演示 。 Also the -xs- infix has been removed , so smallest columns are simply col-1 , col-2 .. col-12 , etc.. -xs-缀也已删除 ,因此最小的列只是col-1col-2 .. col-12等。

col-* - 0 (xs) col-* -0(xs)
col-sm-* - 576px col-sm-* sm- col-sm-* -576像素
col-md-* - 768px col-md-*
col-lg-* - 992px col-lg-* -992px
col-xl-* - 1200px col-xl-* -1200px

Bootstrap 4 Grid Demo Bootstrap 4网格演示

Additionally, Bootstrap 4 includes new auto-layout columns . 此外,Bootstrap 4包括新的自动布局列 。 These also have responsive breakpoints ( col , col-sm , col-md , etc..), but don't have defined % widths. 这些也具有响应断点( colcol-smcol-md等),但是没有定义宽度百分比。 Therefore, the auto-layout columns fill equal width across the row. 因此,自动布局列在行中的宽度相等 。


This article explains more about the Bootstrap grid 本文介绍了有关Bootstrap网格的更多信息


#4楼

I think the confusing aspect of this is the fact that BootStrap 3 is a mobile first responsive system and fails to explain how this affects the col-xx-n hierarchy in that part of the Bootstrap documentation. 我认为这令人困惑的方面是,BootStrap 3是一个移动优先响应系统,并且无法在Bootstrap文档的那部分中解释这如何影响col-xx-n层次结构。 This makes you wonder what happens on smaller devices if you choose a value for larger devices and makes you wonder if there is a need to specify multiple values. 这使您想知道如果为较大的设备选择一个值,在较小的设备上会发生什么,并且使您怀疑是否需要指定多个值。 (You don't) (你不)

I would attempt to clarify this by stating that... Lower grain types (xs, sm) attempt retain layout appearance on smaller screens and larger types (md,lg) will display correctly only on larger screens but will wrap columns on smaller devices. 我将尝试通过声明以下内容来澄清这一点:较小的晶粒类型(xs,sm)尝试在较小的屏幕上保留布局外观,而较大的晶粒类型(md,lg)仅在较大的屏幕上正确显示,但在较小的设备上会包裹列。 The values quoted in previous examples refer to the threshold as which bootstrap degrades the appearance to fit the available screen estate. 先前示例中引用的值是指阈值,因为该引导会降低外观以适合可用的屏幕空间。

What this means in practice is that if you make the columns col-xs-n then they will retain correct appearance even on very small screens, until the window drops to a size that is so restrictive that the page cannot be displayed correctly. 实际上,这意味着,如果将列col-xs-n设置为n,则即使在很小的屏幕上,它们也将保持正确的外观,直到窗口大小减小到无法正确显示页面的程度为止。 This should mean that devices that have a width of 768px or less should show your table as you designed it rather than in degraded (single or wrapped column form). 这应该意味着宽度为768px或更小的设备应在设计时显示表格,而不是以降级(单列或包裹列的形式)显示。 Obviously this still depends on the content of the columns and that's the whole point. 显然,这仍然取决于列的内容,这就是重点。 If the page attempts to display multiple columns of large data, side by side on a small screen then the columns will naturally wrap in a horrible way if you did not account for it. 如果页面尝试在小屏幕上并排显示大数据的多列,那么如果您不考虑这些列,这些列自然会以一种可怕的方式包装。 Therefore, depending on the data within the columns you can decide the point at which the layout is sacificed to display the content adequately. 因此,根据列中的数据,您可以确定要布局的点,以充分显示内容。

eg If your page contains three col-sm-n columns bootstrap would wrap the columns into rows when the page width drops below 992px. 例如,如果您的页面包含三个col-sm-n列,则当页面宽度降至992px以下时,引导程序会将这些列包装为行。 This means that the data is still visible but will require vertical scrolling to view it. 这意味着数据仍然可见,但需要垂直滚动才能查看。 If you do not want your layout to degrade, choose xs (as long as your data can be adequately displayed on a lower resolution device in three columns) 如果您不希望布局降级,请选择xs(只要您的数据可以在三列中以较低分辨率的设备充分显示)

If the horizontal position of the data is important then you should try to choose lower granularity values to retain the visual nature. 如果数据的水平位置很重要,则应尝试选择较低的粒度值以保持外观。 If the position is less important but the page must be visible on all devices then a higher value should be used. 如果位置不太重要,但页面必须在所有设备上可见,则应使用更高的值。

If you choose col-lg-n then the columns will display correctly until the screen width drops below the xs threshold of 1200px. 如果选择col-lg-n,则列将正确显示,直到屏幕宽度降至1200像素的xs阈值以下。


#5楼

The bootstrap docs do explain it, but it still took me a while to get it. 引导文档确实对此进行了解释,但是仍然花了我一段时间。 It makes more sense when I explain it to myself in one of two ways: 当我以两种方式之一向自己解释时,它更有意义:

If you think of the columns starting out horizontally, then you can choose when you want them to stack . 如果您想到的列是水平开始的,那么可以选择何时堆叠它们

For example, if you start with columns: ABC 例如,如果您从以下列开始:ABC

You decide when should they stack to be like this: 您可以决定何时堆叠它们,如下所示:

A 一种

B

C C

If you choose col-lg, then the columns will stack when the width is < 1200px. 如果选择col-lg,则当宽度<1200px时,列将堆叠。

If you choose col-md, then the columns will stack when the width is < 992px. 如果选择col-md,则当宽度<992px时,列将堆叠。

If you choose col-sm, then the columns will stack when the width is < 768px. 如果选择col-sm,则宽度小于768px时,列将堆叠。

If you choose col-xs, then the columns will never stack. 如果选择col-xs,则列将永远不会堆叠。

On the other hand, if you think of the columns starting out stacked, then you can choose at what point they become horizontal : 另一方面,如果您考虑从堆叠开始的列,则可以选择它们在何时变为水平

If you choose col-sm, then the columns will become horizontal when the width is >= 768px. 如果选择col-sm,则宽度> = 768px时,列将变为水平。

If you choose col-md, then the columns will become horizontal when the width is >= 992px. 如果选择col-md,则宽度> = 992px时,列将变为水平。

If you choose col-lg, then the columns will become horizontal when the width is >= 1200px. 如果选择col-lg,则当宽度> = 1200px时,列将变为水平。


#6楼

Device Sizes and class prefix: 设备大小和类前缀:

  • Extra small devices Phones (<768px) - .col-xs- 超小型设备电话(<768px)-. .col-xs-
  • Small devices Tablets (≥768px) - .col-sm- 小型设备平板电脑(≥768px)-.col .col-sm-
  • Medium devices Desktops (≥992px) - .col-md- 中型设备台式机(≥992px)-. .col-md-
  • Large devices Desktops (≥1200px) - .col-lg- 大型设备台式机(≥1200px)-.col .col-lg-

Grid options: 网格选项:

Reference: Grid System 参考: 网格系统

Bootstrap中的col-lg-*,col-md- *和col-sm- *有什么区别?相关推荐

  1. Bootstrap中栅格系统xs,sm,md,lg

    如题,bootstrap中的xs,sm,md,lg的意义 bootstrap版本 v3 xs:xsmall phone 超小屏(自动) sm: small tables 小屏(750px) md: m ...

  2. Bootstrap 之 sm ,lg , md

    Bootstrap中默认最多将屏幕宽度分为12列, 在div平分屏幕中 sm适应小型设备 md适应中型设备 lg适应大型设备

  3. 什么是 bootstrap 中的 break point

    断点是 Bootstrap 中的触发器,用于触发布局响应按照设备或视口大小的变化而变化. 断点是响应式设计的基石. 使用它们来控制您的布局何时可以适应特定的视口或设备大小. 使用 media quer ...

  4. bootstrap中导航、导航栏、表单及自定义表单

    导航: bootstrap中使用列表封装了水平导航,其类样式如: 类名 描述 .nav 给ul或ol,用于清除列表默认样式,并将列表项水平排列 .nav-item 给li,用于布局 .nav-link ...

  5. bootstrap中表格、修饰图片、浮动、背景框、提示框及关闭提示框、元素淡入淡出及jQuery中操作类名

    表格: bootstrap中用类定义了几个风格的表格,使用时给table标签加上类名即可,具体如下: 类名 描述 .table 基础表格:标题加粗,只有水平的淡灰色边框线条,没有垂直方向的线条 .ta ...

  6. bootstrap中轮播图、模态框、提示框/弹出框、滚动监听、弹性布局、响应式flex、多媒体对象

    轮播图: bootstrap封装了轮播图的功能,其具体如下: 类名 描述 .carousel 创建一个轮播图块的容器,实质是做布局用:且此容器应该有一个di属性,其属性值提供给下面左右按钮href锚点 ...

  7. bootstrap中分页、面包屑导航、列表组、卡片、下拉菜单、折叠

    分页: 分页功能是当遇到数据很多时,如果都放到一个页面上,那么找起来很不方便,而且不利于性能.此时采用分页功能就能很好的优化用户体验,可是如果自己开发分页功能,那么就会影响开发效率,bootstrap ...

  8. ng bootstrap css,Angular2学习笔记-ng bootstrap中motal组件使用

    ng bootstrap是一个angular UI bootstrap库,里面包含了一些基本的UI组件(日期选择组件,按钮,下拉框等).目前的版本为v1.0.0-alpha.14,基于angular2 ...

  9. bootstrap中col-xs-*在屏幕缩小时没起作用

    问题描述: 在bootstrap中的col-xs-*在屏幕缩小时没起作用. eg. <div class="container-fluid"><div class ...

最新文章

  1. Spring Boot+Vue从零开始搭建系统(一):项目前端_Vuejs环境搭建
  2. d3.js 简介和安装
  3. python处理pdf 层_Python处理PDF及生成多层PDF实例代码
  4. Mac下使用Wine安装PowerDesigner15
  5. python中pass的用法_python学习之getpass模块使用
  6. 区块链+”来了,区块链金融将如何颠覆传统金融
  7. win2012 安装华为U2000 U2000V200R018C60SPC200 解决”使用isql命令连接SQL Server服务失败“+
  8. ESP32 硬件开发指北 -- 外接FLASH使用指北
  9. Merged Manifest官方文档
  10. 基于stm32f103的俄罗斯方块游戏
  11. 嵌入式系统开发笔记17:CJ/T-188 冷热量表协议解析6
  12. 业聚医疗在港交所上市:市值约76亿港元,钱永勋、刘桂祯夫妇控股
  13. 和讯金融界证券之星 财经网站竞争格局突变
  14. JAVA实现无损word转pdf文件完整代码教程
  15. Battery Historian2.0使用过程中遇到的一些问题
  16. 广告sdk是什么意思?广告SDK分类及用途介绍
  17. Android aab安装到手机
  18. 美团面试全流程详解(一面 + 二面)
  19. oracle复合数据类型
  20. 数据结构与算法实验报告——实验一 链表

热门文章

  1. SAP MDG —— DRF常用工具汇总
  2. python下载文件传到服务器_windows上python上传下载文件到linux服务器指定路径【转】...
  3. Asp.Net 部署IIS10 设置环境变量
  4. Qt笔记 倍速播放菜单
  5. C#之CAD二次开发实例 (13) 图层操作
  6. 斯坦福Introduction to NLP:第十讲关系抽取
  7. 教你怎样破解电脑开机密码
  8. HTML中添加点击链接 进行Skype对话的问题
  9. 2016上半年教师资格证考试《高中数学》真题
  10. Alfred 4常见问题:Alfred找不到我要寻找的文件或应用程序怎么办?