博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Bootstrap栅格系统(布局)
阅读量:7214 次
发布时间:2019-06-29

本文共 2520 字,大约阅读时间需要 8 分钟。

栅格系统(布局)

Bootstrap内置了一套响应式、移动设备优先的流式栅格系统,随着屏幕设备或视口(viewport)尺寸的增加,系统会自动分为最多12列。

我在这里是把Bootstrap中的栅格系统叫做布局。它就是通过一系列的行(row)与列(column)的组合创建页面布局,然后你的内容就可以放入到你创建好的布局当中。下面就简单介绍一下Bootstrap栅格系统的工作原理:

  1. 行(row)必须包含在.container中,以便为其赋予合适的排列(aligment)和内补(padding)。
  2. 使用行(row)在水平方向创建一组列(column)。
  3. 你的内容应当放置于列(column)内,而且,只有列(column)可以作为行(row)的直接子元素。
  4. 类似Predefined grid classes like .row and .col-xs-4 这些预定义的栅格class可以用来快速创建栅格布局。Bootstrap源码中定义的mixin也可以用来创建语义化的布局。
  5. 通过设置padding从而创建列(column)之间的间隔(gutter)。然后通过为第一和最后一样设置负值的margin从而抵消掉padding的影响。
  6. 栅格系统中的列是通过指定1到12的值来表示其跨越的范围。例如,三个等宽的列可以使用三个.col-xs-4来创建

1、原始代码及效果图

			
bootstrap

Hello, world!

Bootstrap has a few easy ways to quickly get started, each one appealing to a different skill level and use case. Read through to see what suits your particular needs.

If you work with Bootstrap's uncompiled source code, you need to compile the LESS files to produce usable CSS files. For compiling LESS files into CSS, we only officially support Recess, which is Twitter's CSS hinter based on less.js.

Within the download you'll find the following directories and files, logically grouping common resources and providing both compiled and minified variations.

  

2、将三个区域显示在同一排,并且平均分成三栏。

首先为三个区域添加一个容器,可以使用div,并且为div添加一个类 <div class="row">.

然后我们为每个小的区域也添加一个容器div,并且为div添加一个类<div class="col-xs-4">

			
bootstrap

Hello, world!

Bootstrap has a few easy ways to quickly get started, each one appealing to a different skill level and use case. Read through to see what suits your particular needs.

If you work with Bootstrap's uncompiled source code, you need to compile the LESS files to produce usable CSS files. For compiling LESS files into CSS, we only officially support Recess, which is Twitter's CSS hinter based on less.js.

Within the download you'll find the following directories and files, logically grouping common resources and providing both compiled and minified variations.

  

3、Bootstrap 网格系统如何跨多个设备工作

如果在一个元素上使用多个不同的上面的样式类,那么元素会根据在不同尺寸选择最合适(匹配最理想的)的样式类。

 

总结:

1..container:用.container包裹页面上的内容即可实现居中对齐。在不同的媒体查询或值范围内都为container设置了max-width,用以匹配栅格系统。

2..col-xs-4:这个类通过"-"分为三个部分,第三个部分的数字作为一个泛指,它的范围是1到12。就是可以把一个区域分为12个栏,这个要和row类联合使用。

 

转载于:https://www.cnblogs.com/Garnett-Boy/p/5602930.html

你可能感兴趣的文章
利用visual VM 分析统计单词频率程序
查看>>
SQL去重复查询
查看>>
OC 属性,点语法
查看>>
SMS设计之我见
查看>>
想要走的路
查看>>
Excel 冻结横格、纵格
查看>>
RHEL5——DNS服务器的搭建
查看>>
服务器简介
查看>>
hibernate主键生成策略
查看>>
Router Configuration<6>
查看>>
Router Configuration<11>
查看>>
大容量分区命令parted
查看>>
从输入 URL 到页面加载完成的过程中都发生了什么事情?
查看>>
实例讲解JQuery中this和$(this)区别
查看>>
centos 7 静态ip地址模板
查看>>
影响系统性能的20个瓶颈
查看>>
shell的详细介绍和编程(上)
查看>>
超市找零简单算法
查看>>
Qt多线程程序设计
查看>>
allowScriptAccess(JS和Flash跨域的互相调用解析)
查看>>