功能强大的Bootstrap使用手册(一)_Javascript教程-查字典教程网
功能强大的Bootstrap使用手册(一)
功能强大的Bootstrap使用手册(一)
发布时间:2016-12-30 来源:查字典编辑
摘要:BootStrap对开发者来说最大的好处就是响应式布局和一些优秀的样式。现在我给大家介绍一些使用BootStrap的步骤和一些常用的东西。1...

BootStrap对开发者来说最大的好处就是响应式布局和一些优秀的样式。

现在我给大家介绍一些使用BootStrap的步骤和一些常用的东西。

1.编写头部

<head> <meta charset="UTF-8"> <> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>LearnBootstrap</title> <> <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"> <> <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css"> <> <!--[if lt IE 9]> <> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <> </head>

2.引入js

这个可以写在body

<> <script src="http://www.jb51.net/cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script> <> <script src="http://www.jb51.net/cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

3.使用container类

container类是一个常用的div类

主要是用居中功能

<div>hello</div>

4.使用栅格化系统

栅格化系统是BootStrap一个非常常用的一个布局系统

简单的使用如下

<div> <> <> <> <div>.col-xs-12 .col-sm-6 .col-md-8.col-xs-12 .col-sm-6 .col-md-8.col-xs-12 .col-sm-6 .col-md-8.col-xs-12 .col-sm-6 .col-md-8.col-xs-12 .col-sm-6 .col-md-8</div> <div>.col-xs-6 .col-md-4</div> </div> <div> <> <div>.col-xs-12 .col-sm-6 .col-md-8</div> <div>.col-xs-6 .col-md-4</div> </div>

可以看到栅格化系统可以根据不同设备调整不同宽度

5.使用表格

<div> <> <div> <> <table> <thead> <tr> <th>表格标题</th> <th>表格标题</th> <th>表格标题</th> </tr> </thead> <tbody> <> <tr> <th>表格内容</th> <th>表格内容</th> <th>表格内容</th> </tr> <> <tr> <th>表格内容</th> <th>表格内容</th> <th>表格内容</th> </tr> <> <tr> <th>表格内容</th> <th>表格内容</th> <th>表格内容</th> </tr> </tbody> </table> </div> </div>

如果是想某一格变颜色也可以在th标签内加类像tr一样

6.使用表单

最基本的用法如下

<div> <form> <> <div> <> <label for="exampleInputEmail1">Email address</label> <> <input type="email" id="exampleInputEmail1" placeholder="Email"> </div> <div> <label for="exampleInputPassword1">Password</label> <input type="password" id="exampleInputPassword1" placeholder="Password"> </div> <div> <label for="exampleInputFile">File input</label> <input type="file" id="exampleInputFile"> <> <p>Example block-level help text here.</p> </div> <div> <label> <input type="checkbox"> Check me out </label> </div> <button type="submit">Submit</button> </form> </div>

如果将form的类设为form-inline则将所有元素显示在同一行

如果将form的类设为form-horizontal则每个form-group显示一行,不过要自己设置宽度

<div> <> <form> <div> <label for="Emai">Email</label> <> <div> <input type="email" placeholder="Email" id="Emai"> </div> </div> <div> <label for="Passwor">Password</label> <div> <input type="password" placeholder="Password" id="Passwor"> </div> </div> <button type="submit">summit</button> </form> </div>

我们通常在注册账号时,信息错误或者正确他会在旁边提示,而且输入框的颜色会不同

Bootstrap给我们提供了这个很实用的功能

<div> <form> <> <> <div> <label for="inputSuccess2">Input with success</label> <input type="text" id="inputSuccess2" aria-describedby="inputSuccess2Status"> <> <span aria-hidden="true"></span> <> <span id="inputSuccess2Status">(success)</span> </div> <> <div> <label for="inputWarning2">Input with warning</label> <input type="text" id="inputWarning2" aria-describedby="inputWarning2Status"> <span aria-hidden="true"></span> <span id="inputWarning2Status">(warning)</span> </div> <> <div> <label for="inputError2">Input with error</label> <input type="text" id="inputError2" aria-describedby="inputError2Status"> <span aria-hidden="true"></span> <span id="inputError2Status">(error)</span> </div> </form> </div>

7.按钮

按钮是必不可少的一样东西

<> <button type="button">(默认样式)Default</button> <> <button type="button">(首选项)Primary</button> <> <button type="button">(成功)Success</button> <> <button type="button">(一般信息)Info</button> <> <button type="button">(警告)Warning</button> <> <button type="button">(危险)Danger</button>

类中还可以添加尺寸

<button type="button">(大按钮)Large button</button> <button type="button">(默认尺寸)Default button</button> <button type="button">(小按钮)Small button</button> <button type="button">(超小尺寸)Extra small button</button>

以上就是Bootstrap的使用步骤和常用用法

用上这个框架后不仅开发的速度上去了,质量也提升了。

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新Javascript教程学习
    热门Javascript教程学习
    编程开发子分类