Bootstrap栅格系统的使用和理解2(2)

流式布局容器
将最外面的布局元素 .container 修改为 .container-fluid,就可以将固定宽度的栅格布局转换为 100% 宽度的布局。

<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="width=device-width, initial-scale=1,user-scalable=0"> <title>container & container-fluid</title> <link href="https://www.jb51.net/lib/bootstrap/css/bootstrap.css"> <!--[if lt IE 9]> <script src="https://www.jb51.net/lib/html5shiv/html5shiv.min.js"></script> <script src="https://www.jb51.net/lib/respond/respond.js"></script> <![endif]--> <!--自己的css文件--> <style> .container{ background: yellowgreen; height: 400px; } .container-fluid{ background: red; height: 100px; } </style> </head> <body> <!--布局容器 没有高度 响应式容器--> <div> </div> <!-- 将最外面的布局元素 .container 修改为 .container-fluid,就可以将固定宽度的栅格布局转换为 100% 宽度的布局。 --> <div> </div> <!--因为 bootstrap 是依赖 jquery 引用jquery文件--> <script src="https://www.jb51.net/lib/jquery/jquery.js"></script> <script src="https://www.jb51.net/lib/bootstrap/js/bootstrap.js"></script> </body> </html>

列偏移
使用 .col-md-offset-* 类可以将列向右侧偏移。这些类实际是通过使用 * 选择器为当前元素增加了左侧的边距(margin)。例如,.col-md-offset-4 类将 .col-md-4 元素向右侧偏移了4个列(column)的宽度。

<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="width=device-width, initial-scale=1"> <title>Bootstrap 模板</title> <link href="https://www.jb51.net/lib/bootstrap/css/bootstrap.css"> <!--[if lt IE 9]> <script src="https://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script> <![endif]--> <style> .row>div{ border: 1px solid #333; background-color: #e0e0e0; } </style> </head> <body> <div> <div> <div>.col-md-4</div> <div>.col-md-4 .col-md-offset-4</div> </div> <div> <div>.col-md-3 .col-md-offset-3</div> <div>.col-md-3 .col-md-offset-3</div> </div> <div> <div>.col-md-6 .col-md-offset-3</div> </div> </div> <script src="https://www.jb51.net/lib/jquery/jquery.js"></script> <script src="https://www.jb51.net/lib/bootstrap/js/bootstrap.js"></script> </body> </html>

列排序

通过使用 .col-md-push-* 和 .col-md-pull-* 类就可以很容易的改变列(column)的顺序。

<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="width=device-width, initial-scale=1"> <title>Bootstrap 模板</title> <link href="https://www.jb51.net/lib/bootstrap/css/bootstrap.css"> <!--[if lt IE 9]> <script src="https://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script> <![endif]--> <style> .row>div{ border: 1px solid #333; background-color: #e0e0e0; } </style> </head> <body> <div> <div> <div>.col-md-9 .col-md-push-3</div> <div>.col-md-3 .col-md-pull-9</div> </div> </div> <script src="https://www.jb51.net/lib/jquery/jquery.js"></script> <script src="https://www.jb51.net/lib/bootstrap/js/bootstrap.js"></script> </body> </html>

以上为初学时,学习到的。有错误请指出。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwfdps.html