bootstrap框架、导航条、下拉菜单、轮播广告carousel、栅格系统布局、标签页tabs、模态框、菜单定位的个人总结,具体详情如下所示:
bootstrap框架
<!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> <!-- Bootstrap --> <link href="https://www.jb51.net/css/bootstrap.min.css"> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[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> </head> <body> <h1>你好</h1> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="https://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> <!-- Include all compiled plugins (below), or include individual files as needed --> <script src="https://www.jb51.net/js/bootstrap.min.js"></script> </body> </html>
导航
<nav role="navigation"><!--导航条、默认样式、role定义内容是一个导航条--> <div><!--container居中固定宽度、c-f自适应大小的导航条--> <div> <!--在响应式浏览器宽度小于一定值时,显示按钮--> <button type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span>Toggle navigation</span> <span></span> <span></span> <span></span> </button> <!--logo图标--> <a href="#">Brand</a> </div> <div><!--包裹代码,在宽度大于一定值时,button和此代码是没有作用的--> <!--导航条导航项目--> <ul> <li><a href="#">a</a></li> <li><a href="#">a</a></li> </ul> </div> </div> </nav>
.navbar-inverse:改变导航条的背景颜色
.container:居中显示
固定导航条会遮盖页面内容,解决办法设置body的*padding-top*
下拉菜单
<li> <a href="#" data-toggle="dropdown">下拉菜单<span></span></a> <ul role="menu"> <li><a href="#">Action</a></li> <li><a href="#">Another action</a></li> <li><a href="#">Something else</a></li> <li></li> <li><a href="#">linkkk/a></li> </ul> </li>
data属性API可以使用所有的Bootstrap插件
轮播广告(carousel)
<div data-ride="carousel"> <!--底部导航点。。。--> <ol> <li data-target="#carousel-example-generic" data-slide-to="0"></li> <li data-target="#carousel-example-generic" data-slide-to="1"></li> <li data-target="#carousel-example-generic" data-slide-to="2"></li> </ol> <!--轮播广告内容--> <div role="listbox"> <div> <img src="https://www.jb51.net/article/…"> <div>……</div> </div> <div> <img src="https://www.jb51.net/article/…"> <div>……</div> </div> </div> <!--左右箭头--> <a href="#carousel-example-generic" role="button" data-slide="prev"> <span></span> <pan>previous</span> </a> <a href="#carousel-example-generic" role="button" data-slide="next"> <span></span> <pan>Next</span> </a> </div>
.data-slide-to索引,指向轮播广告的内容,从0开始
.carousel设置广告框的样式(高度、背景色)
.carousel .item设置广告框的样式(高度、背景色)
栅格系统布局
<div> <div> <div>.col-md-4</div> <div>.col-md-4</div> <div>.col-md-4</div> </div> </div>
标签页tabs
<!--标签--> <ul role="tablist"> <li><a href="#home" role="tab" data-toggle="tab">Home</a></li> <li><a href="#profile" role="tab" data-toggle="tab">Profile</a></li> <li><a href="#messages" role="tab" data-toggle="tab">Messages</a></li> <li><a href="#settings" role="tab" data-toggle="tab">Settings</a></li> </ul> <!--标签的内容--> <div> <div>…</div> <div>…</div> <div>…</div> <div>…</div> </div>
标签页tabs