BootStrap使用笔记+案例(下)

简介: BootStrap使用笔记+案例

BootStrap使用笔记+案例(上):https://developer.aliyun.com/article/1427900


5.案例:登录


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="plugins/bootstrap-3.4.1-dist/css/bootstrap.css">
    <style>
        .c1{
            position: fixed;
            left: 0;
            right: 0;
            margin: 0 auto;
            height: 350px;
            width: 500px;
            top: 200px;
            border: 1px solid #9d9d9d;
            padding: 20px;
            /*圆角边框*/
            border-radius: 5px;
            /*阴影 参数:水平方向 垂直方向 模糊距离 颜色*/
            box-shadow: 5px 5px 20px #aaa;
        }
        .c1 h1{
            text-align: center;
        }
    </style>
</head>
<body>
<div class="c1">
    <h1>用户登录</h1>
    <form>
        <div class="form-group">
            <label for="exampleInputEmail1">用户名或手机号</label>
            <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
        </div>
        <div class="form-group">
            <label for="exampleInputPassword1">密码</label>
            <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
        </div>
        <div class="checkbox">
            <label>
                <input type="checkbox"> Check me out
            </label>
        </div>
        <button type="submit" class="btn btn-primary">登录</button>
    </form>
</div>
</body>
</html>



6.后台管理


Step1:设计


Step2:搭建

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="plugins/bootstrap-3.4.1-dist/css/bootstrap.css">
    <style>
        .c1{
            padding:30px;
        }
        .c2{
            padding-top: 20px;
            padding-bottom: 10px;
            padding-left: 30px;
        }
    </style>
</head>
<body>
<nav class="navbar navbar-default">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <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="#">商城</a>
        </div>
        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li class="active"><a href="#">上海<span class="sr-only">(current)</span></a></li>
                <li><a href="#">北京</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                       aria-expanded="false">APP下载<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">搜索</button>
            </form>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="#">登录</a></li>
                <li><a href="#">注册</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                       aria-expanded="false">我的<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><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>
<div class="c2">
    <button type="button" class="btn btn-success">新建</button>
    <button type="button" class="btn btn-info">修改</button>
    <button type="button" class="btn btn-danger">删除</button>
</div>
<div class="c1">
    <table class="table table-bordered">
          <thead>
            <tr>
              <th>#</th>
              <th>First Name</th>
              <th>Last Name</th>
              <th>Username</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <th scope="row">1</th>
              <td>Mark</td>
              <td>Otto</td>
              <td>@mdo</td>
            </tr>
            <tr>
              <th scope="row">2</th>
              <td>Jacob</td>
              <td>Thornton</td>
              <td>@fat</td>
            </tr>
            <tr>
              <th scope="row">3</th>
              <td>Larry</td>
              <td>the Bird</td>
              <td>@twitter</td>
            </tr>
          </tbody>
    </table>
</div>
</body>
</html>



7.图标


  • BootStrap提供的不多
  • fontawesome组件提供海量图标
https://fontawesome.dashgame.com/


下载


引入

<link rel="stylesheet" href="plugins/font-awesome-4.7.0/css/font-awesome.css">
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="plugins/bootstrap-3.4.1-dist/css/bootstrap.css">
    <link rel="stylesheet" href="plugins/font-awesome-4.7.0/css/font-awesome.css">
    <style>
        .c1{
            padding:30px;
        }
        .c2{
            padding-top: 20px;
            padding-bottom: 10px;
            padding-left: 30px;
        }
    </style>
</head>
<body>
<nav class="navbar navbar-default">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <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="#">商城</a>
        </div>
        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li class="active"><a href="#">上海<span class="sr-only">(current)</span></a></li>
                <li><a href="#">北京</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                       aria-expanded="false">APP下载<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">搜索</button>
            </form>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="#">登录</a></li>
                <li><a href="#">注册</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                       aria-expanded="false">我的<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><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>
<div class="c2">
    <button type="button" class="btn btn-success">
        <i class="fa fa-plus-square" aria-hidden="true"></i> 新建
    </button>
    <button type="button" class="btn btn-info">
        <i class="fa fa-pencil-square-o" aria-hidden="true"></i> 修改
    </button>
    <button type="button" class="btn btn-danger">
        <i class="fa fa-trash" aria-hidden="true"></i> 删除
    </button>
</div>
<div class="c1">
    <table class="table table-bordered">
          <thead>
            <tr>
              <th>#</th>
              <th>First Name</th>
              <th>Last Name</th>
              <th>Username</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <th scope="row">1</th>
              <td>Mark</td>
              <td>Otto</td>
              <td>@mdo</td>
            </tr>
            <tr>
              <th scope="row">2</th>
              <td>Jacob</td>
              <td>Thornton</td>
              <td>@fat</td>
            </tr>
            <tr>
              <th scope="row">3</th>
              <td>Larry</td>
              <td>the Bird</td>
              <td>@twitter</td>
            </tr>
          </tbody>
    </table>
</div>
</body>
</html>


8.BootStrap依赖


BootStrap依赖JavaScript的类库,jQuery。


  • 下载
https://jquery.com/


在页面上应用BootStrap的javaScript类库


Step1:引入

<script src="static/js/jquery-3.6.3.min.js"></script>
<script src="plugins/bootstrap-3.4.1-dist/js/bootstrap.min.js"></script>


Step2:测试


这里使用一个模态框测试

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="plugins/bootstrap-3.4.1-dist/css/bootstrap.css">
    <link rel="">
</head>
<body>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
  Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>
<script src="static/js/jquery-3.6.3.min.js"></script>
<script src="plugins/bootstrap-3.4.1-dist/js/bootstrap.min.js"></script>
</body>
</html>


目录
相关文章
|
前端开发
前端基础 - Bootstrap简单案例
前端基础 - Bootstrap简单案例
60 0
|
7月前
|
前端开发
bootstrap组件的案例代码
bootstrap组件的案例代码
|
7月前
|
前端开发
bootstrap样式代码案例
bootstrap样式代码案例
|
7月前
|
前端开发 Python
BootStrap使用笔记+案例(上)
BootStrap使用笔记+案例
81 0
|
7月前
|
前端开发
bootstrap例子笔记
bootstrap例子笔记
|
7月前
|
移动开发 前端开发 HTML5
bootstrap笔记
bootstrap笔记
|
前端开发
bootstrap组件的案例代码
bootstrap组件的案例代码
147 0
bootstrap组件的案例代码
|
前端开发
bootstrap样式代码案例
bootstrap样式代码案例
118 0
bootstrap样式代码案例
|
前端开发
Bootstrap栅格系统 案例
Bootstrap栅格系统 案例
113 0
Bootstrap栅格系统 案例
|
前端开发
后端小白的Bootstrap笔记(三)
后端小白的Bootstrap笔记(三)
129 0