<h3>图标</h3> <span class="glyphicon glyphicon-home"></span> <span class="glyphicon glyphicon-signal"></span> <span class="glyphicon glyphicon-cog"></span> <span class="glyphicon glyphicon-apple"></span> <span class="glyphicon glyphicon-trash"></span> <span class="glyphicon glyphicon-play-circle"></span> <span class="glyphicon glyphicon-headphones"></span>2、按钮:
<h3>按钮</h3> <button type="button" class="btn btn-default">按钮</button> <button type="button" class="btn btn-primary">primary</button> <button type="button" class="btn btn-success">success</button> <button type="button" class="btn btn-info">info</button> <button type="button" class="btn btn-warning">warning</button> <button type="button" class="btn btn-danger">danger</button>
3、按钮尺寸:
<h3>按钮尺寸</h3> <button type="button" class="btn btn-default">按钮</button> <button type="button" class="btn btn-primary btn-lg">primary</button> <button type="button" class="btn btn-success btn-sm">success</button> <button type="button" class="btn btn-info btn-xs">info</button>4、把图标显示在按钮里:
<h3>把图标显示在按钮里</h3> <button type="button" class="btn btn-default"><span class="glyphicon glyphicon-home"></span> 按钮</button>5、下拉菜单:
<p class="dropdown"> <button class="btn btn-primary dropdown-toggle" type="button" ID="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> <span ID="dropdown-Title">菜单一</span> <span class="caret"></span> </button> <ul class="dropdown-menu" aria-labelledby="dropdownMenu1"> <li><a href="#" class="dropdown-item">菜单一</a></li> <li><a href="#" class="dropdown-item">菜单二</a></li> <li><a href="#" class="dropdown-item">菜单三</a></li> </ul> </p>
交互:监听每个菜单的点击事件,点击之后在Title显示当前菜单
$('.dropdown-item').click(function () { $('#dropdown-Title').text($(this).text()); });6、输入框:
<h3>输入框</h3> <p class="input-group"> <span class="glyphicon glyphicon-user"></span> <input type="text" placeholder="username"> </p> <p class="input-group"> <span class="glyphicon glyphicon-lock"></span> <input type="password" placeholder="password"> </p>7、导航栏:
<h3>导航栏</h3> <nav class="navbar navbar-inverse navbar-fixed-top"> <p ID="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#about">About</a></li> <li><a href="#contact">Contact</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span class="caret"></span></a> <ul class="dropdown-menu" role="menu"> <li><a href="#">Action</a></li> <li><a href="#">Another action</a></li> <li class="pIDer"></li> <li class="dropdown-header">Nav header</li> <li><a href="#">Separated link</a></li> </ul> </li> </ul> </p><!--/.nav-collapse --> </p> </nav>8、表单:
<h3>表单</h3> <form> <p class="form-group"> <span class="glyphicon glyphicon-user"></span> <input type="email" ID="exampleinputEmail1" placeholder="Enter email"> </p> <p class="form-group"> <span class="glyphicon glyphicon-lock"></span> <input type="password" ID="exampleinputPassword1" placeholder="Password"> </p> <p class="form-group"> <label for="exampleinputfile">file input</label> <input type="file" ID="exampleinputfile"> <p class="help-block">Example block-level help text here.</p> </p> <p class="checkBox"> <label> <input type="checkBox"> Check me out </label> </p> <button type="submit" class="btn btn-default">submit</button> </form>9、警告框:
<h3>警告框</h3> <p class="alert alert-warning alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hIDden="true">×</span></button> <strong>Warning!</strong> Better check yourself, you're not looking too good. </p> <p class="alert alert-success" role="alert"> <a href="#" class="alert-link">success!</a> </p> <p class="alert alert-info" role="alert"> <a href="#" class="alert-link">info!</a> </p> <p class="alert alert-warning" role="alert"> <a href="#" class="alert-link">warning!</a> </p> <p class="alert alert-danger" role="alert"> <a href="#" class="alert-link">danger!</a> </p>10、进度条:
<h3>进度条</h3> <p class="progress"> <p class="progress-bar" role="progressbar" aria-valueNow="70" aria-valuemin="0" aria-valuemax="100" style="wIDth: 60%;"> 70% </p> </p>11、靠右排列
一般我们是用float:right来实现向右浮动的功能的,但是这里面右涉及了清除浮动、调整右边的margin、上下的margin等等问题,在bootstrap当然要用他的方法,只要添加一个class:pull-right就可以解决:
<span style="Font-size: 30px;">item1</span><p class="pull-right">item2</p>
这第一行是要跟第二行在一个水平线上的,所以第一行不能用<h1>之类的,因为这种元素自带换行功能。
12、tab的使用tab可以方便的在一个页面里面切换显示的内容,bootstrap的tab使用非常简单:
<ul ID="myTab" class="nav nav-tabs"> <li role="presentation" class="active"><a href="#tab1" data-toggle="tab">tab1</a></li> <li role="presentation"><a href="#tab2" data-toggle="tab">tab2</a></li> <li role="presentation"><a href="#tab3" data-toggle="tab">tab3</a></li> </ul> <span>这是宝贝管理页面</span> <p ID="myTabContent" class="tab-content"> <p ID="tab1" class="tab-pane active"> <p>这是tab1</p> </p> <p ID="tab2" class="tab-pane"> <p>这是tab2</p> </p> <p ID="tab3" class="tab-pane"> <p>这是tab3</p> </p> </p>
在Js可以方便的捕捉tab的切换,并做出相应的改变,比如当第二个页面是加载一些数据,那么我等到切换到第二个页面我再去加载:
$('a[data-toggle="tab"]').on('shown.bs.tab',function (e) { var activeTab = $(e.target).text(); alert(activeTab); });13、bootstrap-table
一个可以通过AJAX请求Json数据并生成表格的插件
项目地址:
https://github.com/wenzhixin/bootstrap-table
14、通知消息组件<1>下载地址:https://github.com/CodeSeven/toastr
<2>文档:http://www.ithao123.cn/content-2414918.HTML
<3>引入:在下载的文件里找到build文件夹,引入里面的toastr.min.Js和toastr.CSS
<4>使用:此提示消息默认是显示在浏览器的右上角,我们可以在初始化里面改为顶部居中显示:
toastr.options.positionClass = 'toast-top-center';//显示位置
位置显示的设定有如下选项:
toast-top-righttoast-botton-righttoash-bottom-lefttoast-top-lefttoast-top-full-wIDth 这个是在网页顶端,宽度铺满整个屏幕toast-bottom-full-wIDthtoast-top-center顶端中间toast-bottom-center
然后在我们需要显示的时候这样调用就行了:
toastr.success('提交数据成功');toastr.error('Error');toastr.warning('只能选择一行进行编辑');toastr.info('info');15、AJAX请求
按钮:
<button class="btn btn-link"> 换个密码 </button>
Js:
$('.btn').on('click',function () { $.post('xxx') .done(function (result) { var Json = AJAXResultShow(result); if (Json.result_code == 0) $('#pwdID').text(Json.data1); }) .fail(function () { }) .always(function () { }); });16、bootstrap-switch
(1)此组件不属于bootstrap,他需要单独引入bootstrap-switch.min.Js和bootstrap-switch.min.CSS;
(2)下载地址:http://www.bootCSS.com/p/bootstrap-switch/
(3)使用方法:
添加框架:
<link href="bootstrap.CSS" rel="stylesheet"><link href="bootstrap-switch.CSS" rel="stylesheet"><script src="jquery.Js"></script><script src="bootstrap-switch.Js"></script>
在HTML中添加组件:
<input type="checkBox" name="my-checkBox" checked>
在Js中初始化:
$("[name='my-checkBox']").bootstrapSwitch();
可以在初始化中直接对状态进行设定:
$("#isOpenCheckBox").bootstrapSwitch('state',false);
切换状态:
$('#isOpenCheckBox').bootstrapSwitch('toggleState');
监听切换事件:
$('#isOpenCheckBox').on('switchChange.bootstrapSwitch', function (event,state) { alert(state);// true || false });
总结:以上就是本篇文的全部内容,希望能对大家的学习有所帮助。 总结
以上是内存溢出为你收集整理的BootStrap学习笔记之BootStrap常用组件介绍全部内容,希望文章能够帮你解决BootStrap学习笔记之BootStrap常用组件介绍所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)