Bootstrap框架 简单使用
程序员文章站
2022-03-20 17:21:39
Bootstrap框架 简单使用 [TOC] 什么是Bootstrap Bootstrap官网 下载 Bootstrap 项目结构 Bootstrap 简单使用 根据下面样式用Bootstrap 实现① 导入 Bootstrap 去 Bootstrap 复制需要的样式代码 根基自己需求进行修改 继续 ......
bootstrap框架 简单使用
什么是bootstrap
""" bootstrap是美国twitter公司的设计师mark otto和jacob thornton合作基于html、css、javascript 开发的简洁、直观、强悍的[前端]开发框架,使得 web 开发更加快捷。bootstrap提供了优雅的html和css规范, 它即是由动态css语言less写成。bootstrap一经推出后颇受欢迎,一直是github上的热门开源项目, 包括nasa的msnbc(微软全国广播公司)的breaking news都使用了该项目,国内一些移动开发者较为熟悉的框架, 如wex5前端开源框架等,也是基于bootstrap源码进行性能优化而来。 """
下载 bootstrap
项目结构
#目录结构 bootstrap/ ├── css/ │ ├── bootstrap.css #开发环境下的css样式 │ ├── bootstrap.css.map │ ├── bootstrap.min.css │ ├── bootstrap.min.css.map #生产环境下的css样式(推荐) │ ├── bootstrap-theme.css │ ├── bootstrap-theme.css.map │ ├── bootstrap-theme.min.css │ └── bootstrap-theme.min.css.map ├── js/ │ ├── bootstrap.js #开发环境下的js样式 │ └── bootstrap.min.js #生产环境下的js样式(推荐) └── fonts/ #字体相关 ├── glyphicons-halflings-regular.eot ├── glyphicons-halflings-regular.svg ├── glyphicons-halflings-regular.ttf ├── glyphicons-halflings-regular.woff └── glyphicons-halflings-regular.woff2
<!doctype html> <html lang="zh-cn"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <!-- 移动设备优先 --> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! --> <title>bootstrap 101 template</title> <!-- bootstrap --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet"> <!-- html5 shim 和 respond.js 是为了让 ie8 支持 html5 元素和媒体查询(media queries)功能 --> <!-- 警告:通过 file:// 协议(就是直接将 html 页面拖拽到浏览器中)访问页面时 respond.js 不起作用 --> <!--[if lt ie 9]> <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script> <!--兼容移动设备--> <![endif]--> </head> <body> <h1>你好,世界!</h1> <!-- jquery (bootstrap 的所有 javascript 插件都依赖 jquery,所以必须放在前边) --> <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script> <!-- 加载 bootstrap 的所有 javascript 插件。你也可以根据需要只加载单个插件。 --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script> </body> </html>
bootstrap 简单使用
根据下面样式用bootstrap 实现①
-
导入 bootstrap
去 bootstrap 复制需要的样式代码
根基自己需求进行修改
<!doctype html> <html lang="zh-cn"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! --> <title>bootstrap 101 template</title> <!-- bootstrap --> <link href="bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <div class="container"> <div class="page-header"> <h1>信息收集卡 <small>共三步</small> </h1> </div> </div> <script src="jquery.js"></script> <script src="bootstrap-3.3.7/js/bootstrap.min.js"></script> </body> </html>
继续拷贝(根据自己需求按照进行修改)
<!--进度条代码--> <div class="progress"> <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: 40%"> <span class="sr-only">40% complete (success)</span> </div> </div>
修改
<div class="progress"> <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 33%;"> 1/3 </div> </div>
经过一系列拷贝改动之后 (代码)
<!doctype html> <html lang="zh-cn"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! --> <title>bootstrap 101 template</title> <!-- bootstrap --> <link href="bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <div class="container"> <!-- 布局容器 --> <div class="page-header"> <!-- 页头 --> <h1>信息收集卡 <small>共三步</small> <!-- 小字体显示 --> </h1> </div> <div class="progress"> <!-- 绿色进度条 --> <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 33%;"> <!-- style="width:xx%; 调整进度% --> 1/3 <!-- 进度条显示数值 --> </div> </div> <div class="panel panel-primary"> <!-- 蓝色面板 --> <div class="panel-heading"> <h3 class="panel-title">基本信息 <!-- 面板标题 --><span class="glyphicon glyphicon-pushpin pull-right"><!-- 图标 pull-right 右浮 --></span> </h3> </div> <div class="panel-body"> <!-- 面板内容 --> <div class="row"> <!-- 栅格每行 --> <div class="col-md-4 col-md-offset-1"> <!-- col-md-4栅格每行占4列 col-md-offset-1往右偏一列 --> <form class="form-horizontal"> <!-- 水平排列的form表单 --> <div class="form-group"> <!-- div边距样式 --> <label for="username" class="col-sm-2 control-label">姓名</label><!-- 关联input框 --> <div class="col-sm-10"> <input type="text" class="form-control" id="username" placeholder="姓名"> <!-- input框 class="form-control"样式 框内显示placeholder="姓名" --> </div> </div> <div class="form-group"> <label for="phone" class="col-sm-2 control-label">手机</label> <div class="col-sm-10"> <input type="text" class="form-control" id="phone" placeholder="手机"> </div> </div> <div class="form-group"> <label for="email" class="col-sm-2 control-label">邮箱</label> <div class="col-sm-10"> <input type="text" class="form-control" id="email" placeholder="password"> </div> </div> <div class="form-group"> <label for="inputpassword3" class="col-sm-2 control-label">密码</label> <div class="col-sm-10"> <input type="password" class="form-control" id="inputpassword3" placeholder="password"> </div> </div> <div class="form-group"> <label for="headpic" class="col-sm-2 control-label">头像</label> <div class="col-sm-10"> <input type="file" id="headpic"> <!-- type="file"选择文件 id="headpic"样式 --> <p class="help-block">只支持png\jpg\gif等格式的文件</p> <!-- 提示文本 --> </div> </div> <div class="form-group"> <label for="headpic" class="col-sm-2 control-label">属性</label> <div class="col-sm-10"> <div class="radio"> <!-- 圆圈选择样式 --> <label> <input type="radio" name="optionsradios" id="optionsradios1" value="option1" checked>我是一个好人<!-- type="radio"圆圈选择 --> </label> </div> <div class="radio"> <label> <input type="radio" name="optionsradios" id="optionsradios2" value="option1" checked>我是一个好人 </label> </div> <div class="radio"> <label> <input type="radio" name="optionsradios" id="optionsradios3" value="option1" checked>我是一个好人 </label> </div> </div> </div> </form> </div> </div> </div> </div> <button class="btn btn-success pull-right">下一步</button><!-- class="btn btn-success pull-right"蓝色按钮 右浮 --> </div> <script src="jquery.js"></script> <script src="bootstrap-3.3.7/js/bootstrap.min.js"></script> </body> </html>
大功告成
根据下面样式用bootstrap 实现②
<!doctype html> <html lang="zh-cn"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! --> <title>bootstrap 101 template</title> <link href="bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet"> <style> .cc { margin-top: 20px !important; } table td { text-align: center; height: 30px; padding-top: 10px; } </style> <!-- 上边距 --> <!-- 列表字体样式 --> </head> <body> <nav class="navbar navbar-inverse"><!-- 导航条 class="navbar navbar-inverse"黑色导航--> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">brand</a> </div> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li class="active"><a href="#">link <span class="sr-only">(current)</span></a></li> <li><a href="#">link</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">dropdown <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="#">action</a></li> <li><a href="#">another action</a></li> <li><a href="#">something else here</a></li> <li role="separator" class="divider"></li> <li><a href="#">separated link</a></li> <li role="separator" class="divider"></li> <li><a href="#">one more separated link</a></li> </ul> </li> </ul> <form class="navbar-form navbar-left"> <div class="form-group"> <input type="text" class="form-control" placeholder="search"> </div> <button type="submit" class="btn btn-default">submit</button> </form> <ul class="nav navbar-nav navbar-right"> <li><a href="#">link</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">dropdown <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="#">action</a></li> <li><a href="#">another action</a></li> <li><a href="#">something else here</a></li> <li role="separator" class="divider"></li> <li><a href="#">separated link</a></li> </ul> </li> </ul> </div> </div> </nav> <div class="container"><!-- 布局容器 --> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">panel title</h3><!-- 列表标题 --> </div> <div class="panel-body"> <div class="clearfix"><!-- 清除浮动 --> <form class="form-inline pull-left"> <!-- form表单 行内 左浮 --> <div class="form-group"> <input type="email" class="form-control" id="exampleinputemail2" placeholder="搜索"> </div> <button type="submit" class="btn btn-primary">搜索</button><!-- btn btn-primary蓝色按钮 --> </form> <button class="btn btn-success pull-right">添加</button><!-- btn btn-primary绿色按钮 --> </div> <table class="table table-bordered table-striped table-hover cc"><!-- 列表 带表格带条纹带鼠标悬浮效果 --> <thead> <tr> <th>#</th> <th>name</th> <th>age</th> <th>sex</th> <th>hobby</th> <th>operation</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>小猪佩奇</td> <td>8</td> <td>不详</td> <td>不知道</td> <td> <button class="btn btn-warning btn-sm"><span class="glyphicon glyphicon-pencil"></span>编辑<!-- btn-warning btn-sm橙色按钮小 --> </button> <button class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-remove"></span>删除<!-- btn-danger btn-sm红色按钮小 --> </button> </td> </tr> <tr> <td>1</td> <td>小猪佩奇</td> <td>8</td> <td>不详</td> <td>不知道</td> <td> <button class="btn btn-warning btn-sm"><span class="glyphicon glyphicon-pencil"></span>编辑 </button> <button class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-remove"></span>删除 </button> </td> </tr> <tr> <td>1</td> <td>小猪佩奇</td> <td>8</td> <td>不详</td> <td>不知道</td> <td> <button class="btn btn-warning btn-sm"><span class="glyphicon glyphicon-pencil"></span>编辑 </button> <button class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-remove"></span>删除 </button> </td> </tr> <tr> <td>1</td> <td>小猪佩奇</td> <td>8</td> <td>不详</td> <td>不知道</td> <td> <button class="btn btn-warning btn-sm"><span class="glyphicon glyphicon-pencil"></span>编辑 </button> <button class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-remove"></span>删除 </button> </td> </tr> <tr> <td>1</td> <td>小猪佩奇</td> <td>8</td> <td>不详</td> <td>不知道</td> <td> <button class="btn btn-warning btn-sm"><span class="glyphicon glyphicon-pencil"></span>编辑 </button> <button class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-remove"></span>删除 </button> </td> </tr> </tbody> </table> <nav aria-label="page navigation" class="pull-right"><!-- 分页插件 --> <ul class="pagination"> <li> <a href="#" aria-label="previous"> <span aria-hidden="true">«</span> </a> </li> <li><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> <li><a href="#">5</a></li> <li> <a href="#" aria-label="next"> <span aria-hidden="true">»</span> </a> </li> </ul> </nav> </div> </div> <div> </div> </div> </body> </html>
表格格式
<table> <thead> <tr> <th>标题</th> </tr> </thead> <tbody> <tr> <td>行内容</td> </tr> </tbody> </table>
bootstrap 按钮颜色
<!-- standard button --> <button type="button" class="btn btn-default">(默认样式 白色)default</button> <!-- provides extra visual weight and identifies the primary action in a set of buttons --> <button type="button" class="btn btn-primary">(首选项 蓝色)primary</button> <!-- indicates a successful or positive action --> <button type="button" class="btn btn-success">(成功 绿色)success</button> <!-- contextual button for informational alert messages --> <button type="button" class="btn btn-info">(一般信息 浅蓝色)info</button> <!-- indicates caution should be taken with this action --> <button type="button" class="btn btn-warning">(警告 橙色)warning</button> <!-- indicates a dangerous or potentially negative action --> <button type="button" class="btn btn-danger">(危险 红色)danger</button> <!-- deemphasize a button by making it look like a link while maintaining button behavior --> <button type="button" class="btn btn-link">(链接 透明)link</button>
上一篇: BFS(三):双向广度优先搜索
下一篇: python第一天学习笔记