BootStrap使用笔记+案例

前端开发 第三节BootStrap

BootStrap

BootStrap是别人写好的CSS样式,如何使用BootStrap:

  • 下载BootStrap

    https://v3.bootcss.com/
    
  • 使用

    • 在页面上引入BootStrap
    • 编写HTML时,按照BootStrap的规定来编写 + 自定制

开发版本:bootstrap.css

生产版本:bootstrap.min.css (去掉空字符,换行符减少大小,产品上线使用)

1.初识BootStrap

DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Titletitle>
    
    <link rel="stylesheet" href="plugins/bootstrap-3.4.1-dist/css/bootstrap.css">

    
    <link rel="stylesheet" href="plugins/bootstrap-3.4.1-dist/css/bootstrap.min.css">
head>
<body>
    <input type="button" value="提交">
    <input type="button" value="提交" class="btn-primary">
    <input type="button" value="提交" class="btn-success">
    <input type="button" value="提交" class="btn-danger">
    <input type="button" value="提交" class="btn-danger btn-xs">
body>
html>

BootStrap使用笔记+案例_第1张图片

2.导航条

Step1:打开BootStrap v3官网的组件

BootStrap使用笔记+案例_第2张图片

Step2:打开导航条

BootStrap使用笔记+案例_第3张图片

Step3:找到自己喜欢的导航条样式,复制代码

BootStrap使用笔记+案例_第4张图片

Step4:粘贴在body中,更改自己所需内容

DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Titletitle>
    <link rel="stylesheet" href="plugins/bootstrap-3.4.1-dist/css/bootstrap.css">
head>
<body>
    <nav class="navbar navbar-default">
  <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 navigationspan>
        <span class="icon-bar">span>
        <span class="icon-bar">span>
        <span class="icon-bar">span>
      button>
      <a class="navbar-brand" href="#">商城a>
    div>

    
    <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="#">Actiona>li>
            <li><a href="#">Another actiona>li>
            <li><a href="#">Something else herea>li>
            <li role="separator" class="divider">li>
            <li><a href="#">Separated linka>li>
            <li role="separator" class="divider">li>
            <li><a href="#">One more separated linka>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="#">Actiona>li>
            <li><a href="#">Another actiona>li>
            <li><a href="#">Something else herea>li>
            <li role="separator" class="divider">li>
            <li><a href="#">Separated linka>li>
          ul>
        li>
      ul>
    div>
  div>
nav>
body>
html>

BootStrap使用笔记+案例_第5张图片

Step5:PyCharm小技巧:Reformat Code 规范缩进

BootStrap使用笔记+案例_第6张图片

3.栅格系统

Step1:打开官网中的全局CSS样式

BootStrap使用笔记+案例_第7张图片

Step2:根据官网文档可知,系统会自动分为最多12列。

BootStrap使用笔记+案例_第8张图片

Step3:使用

BootStrap使用笔记+案例_第9张图片

使用col-xs-6,各分6格:

DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Titletitle>
    <link rel="stylesheet" href="plugins/bootstrap-3.4.1-dist/css/bootstrap.css">
head>
<body>
    <div>
        <div class="col-xs-6" style="background-color: red">1div>
        <div class="col-xs-6" style="background-color: blue">2div>
    div>
body>
html>

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-u5RLMC6J-1674147563450)(../前端/image-20230119190156426-167413617137919.png)]

  • 分类

    • 响应式,根据屏幕宽度不同自动调整

      .col-sm-	1170px
      .col-md-	970px
      .col-lg-	750px
      
    • 非响应式

      .col-xs
      
    • 列偏移

      <div class="col-sm-offset-2 col-xs-6" style="background-color: blue">2div>
      

      [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-T7TAQrnh-1674147563451)(../前端/image-20230119191054046-167413617993921.png)]

4.案例:博客页面

Step1:设计页面

BootStrap使用笔记+案例_第10张图片

Step2:使用BootStrap进行搭建

DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Titletitle>
    <link rel="stylesheet" href="plugins/bootstrap-3.4.1-dist/css/bootstrap.css">
head>
<body>
<nav class="navbar navbar-default">
    <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 navigationspan>
                <span class="icon-bar">span>
                <span class="icon-bar">span>
                <span class="icon-bar">span>
            button>
            <a class="navbar-brand" href="#">商城a>
        div>

        
        <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="#">Actiona>li>
                        <li><a href="#">Another actiona>li>
                        <li><a href="#">Something else herea>li>
                        <li role="separator" class="divider">li>
                        <li><a href="#">Separated linka>li>
                        <li role="separator" class="divider">li>
                        <li><a href="#">One more separated linka>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="#">Actiona>li>
                        <li><a href="#">Another actiona>li>
                        <li><a href="#">Something else herea>li>
                        <li role="separator" class="divider">li>
                        <li><a href="#">Separated linka>li>
                    ul>
                li>
            ul>
        div>
    div>
nav>

<div class="container-fluid clearfix">
    <div class="col-sm-9">
        <div class="media">
            <div class="media-left">
                <a href="#">
                    <img class="media-object" data-src="holder.js/64x64" alt="64x64"
                         src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iNjQiIGhlaWdodD0iNjQiIHZpZXdCb3g9IjAgMCA2NCA2NCIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+PCEtLQpTb3VyY2UgVVJMOiBob2xkZXIuanMvNjR4NjQKQ3JlYXRlZCB3aXRoIEhvbGRlci5qcyAyLjYuMC4KTGVhcm4gbW9yZSBhdCBodHRwOi8vaG9sZGVyanMuY29tCihjKSAyMDEyLTIwMTUgSXZhbiBNYWxvcGluc2t5IC0gaHR0cDovL2ltc2t5LmNvCi0tPjxkZWZzPjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+PCFbQ0RBVEFbI2hvbGRlcl8xODVjYTJhYzBmOCB0ZXh0IHsgZmlsbDojQUFBQUFBO2ZvbnQtd2VpZ2h0OmJvbGQ7Zm9udC1mYW1pbHk6QXJpYWwsIEhlbHZldGljYSwgT3BlbiBTYW5zLCBzYW5zLXNlcmlmLCBtb25vc3BhY2U7Zm9udC1zaXplOjEwcHQgfSBdXT48L3N0eWxlPjwvZGVmcz48ZyBpZD0iaG9sZGVyXzE4NWNhMmFjMGY4Ij48cmVjdCB3aWR0aD0iNjQiIGhlaWdodD0iNjQiIGZpbGw9IiNFRUVFRUUiLz48Zz48dGV4dCB4PSIxMy4xNzMwMDQxNTAzOTA2MjUiIHk9IjM2LjUiPjY0eDY0PC90ZXh0PjwvZz48L2c+PC9zdmc+"
                         data-holder-rendered="true" style="width: 64px; height: 64px;">
                a>
            div>
            <div class="media-body">
                <h4 class="media-heading">Media headingh4>
                Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras
                purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate
                fringilla. Donec lacinia congue felis in faucibus.
            div>
        div>
        <div class="media">
            <div class="media-left">
                <a href="#">
                    <img class="media-object" data-src="holder.js/64x64" alt="64x64"
                         src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iNjQiIGhlaWdodD0iNjQiIHZpZXdCb3g9IjAgMCA2NCA2NCIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+PCEtLQpTb3VyY2UgVVJMOiBob2xkZXIuanMvNjR4NjQKQ3JlYXRlZCB3aXRoIEhvbGRlci5qcyAyLjYuMC4KTGVhcm4gbW9yZSBhdCBodHRwOi8vaG9sZGVyanMuY29tCihjKSAyMDEyLTIwMTUgSXZhbiBNYWxvcGluc2t5IC0gaHR0cDovL2ltc2t5LmNvCi0tPjxkZWZzPjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+PCFbQ0RBVEFbI2hvbGRlcl8xODVjYTJhYzBmOCB0ZXh0IHsgZmlsbDojQUFBQUFBO2ZvbnQtd2VpZ2h0OmJvbGQ7Zm9udC1mYW1pbHk6QXJpYWwsIEhlbHZldGljYSwgT3BlbiBTYW5zLCBzYW5zLXNlcmlmLCBtb25vc3BhY2U7Zm9udC1zaXplOjEwcHQgfSBdXT48L3N0eWxlPjwvZGVmcz48ZyBpZD0iaG9sZGVyXzE4NWNhMmFjMGY4Ij48cmVjdCB3aWR0aD0iNjQiIGhlaWdodD0iNjQiIGZpbGw9IiNFRUVFRUUiLz48Zz48dGV4dCB4PSIxMy4xNzMwMDQxNTAzOTA2MjUiIHk9IjM2LjUiPjY0eDY0PC90ZXh0PjwvZz48L2c+PC9zdmc+"
                         data-holder-rendered="true" style="width: 64px; height: 64px;">
                a>
            div>
            <div class="media-body">
                <h4 class="media-heading">Media headingh4>
                Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras
                purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate
                fringilla. Donec lacinia congue felis in faucibus.
            div>
        div>
        <div class="media">
            <div class="media-left">
                <a href="#">
                    <img class="media-object" data-src="holder.js/64x64" alt="64x64"
                         src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iNjQiIGhlaWdodD0iNjQiIHZpZXdCb3g9IjAgMCA2NCA2NCIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+PCEtLQpTb3VyY2UgVVJMOiBob2xkZXIuanMvNjR4NjQKQ3JlYXRlZCB3aXRoIEhvbGRlci5qcyAyLjYuMC4KTGVhcm4gbW9yZSBhdCBodHRwOi8vaG9sZGVyanMuY29tCihjKSAyMDEyLTIwMTUgSXZhbiBNYWxvcGluc2t5IC0gaHR0cDovL2ltc2t5LmNvCi0tPjxkZWZzPjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+PCFbQ0RBVEFbI2hvbGRlcl8xODVjYTJhYzBmOCB0ZXh0IHsgZmlsbDojQUFBQUFBO2ZvbnQtd2VpZ2h0OmJvbGQ7Zm9udC1mYW1pbHk6QXJpYWwsIEhlbHZldGljYSwgT3BlbiBTYW5zLCBzYW5zLXNlcmlmLCBtb25vc3BhY2U7Zm9udC1zaXplOjEwcHQgfSBdXT48L3N0eWxlPjwvZGVmcz48ZyBpZD0iaG9sZGVyXzE4NWNhMmFjMGY4Ij48cmVjdCB3aWR0aD0iNjQiIGhlaWdodD0iNjQiIGZpbGw9IiNFRUVFRUUiLz48Zz48dGV4dCB4PSIxMy4xNzMwMDQxNTAzOTA2MjUiIHk9IjM2LjUiPjY0eDY0PC90ZXh0PjwvZz48L2c+PC9zdmc+"
                         data-holder-rendered="true" style="width: 64px; height: 64px;">
                a>
            div>
            <div class="media-body">
                <h4 class="media-heading">Media headingh4>
                Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras
                purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate
                fringilla. Donec lacinia congue felis in faucibus.
            div>
        div>
    div>
    <div class="col-sm-3">
        <div class="panel panel-primary">
            <div class="panel-heading">最新推荐div>
            <div class="panel-body">
                Panel content
            div>
        div>
        <div class="panel panel-success">
            <div class="panel-heading">榜单排行div>
            <div class="panel-body">
                Panel content
            div>
        div>
    div>
div>

body>
html>

BootStrap使用笔记+案例_第11张图片

5.案例:登录

DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Titletitle>
    <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>

BootStrap使用笔记+案例_第12张图片

6.后台管理

Step1:设计

BootStrap使用笔记+案例_第13张图片

Step2:搭建

DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Titletitle>
    <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">
        
        <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 navigationspan>
                <span class="icon-bar">span>
                <span class="icon-bar">span>
                <span class="icon-bar">span>
            button>
            <a class="navbar-brand" href="#">商城a>
        div>

        
        <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="#">Actiona>li>
                        <li><a href="#">Another actiona>li>
                        <li><a href="#">Something else herea>li>
                        <li role="separator" class="divider">li>
                        <li><a href="#">Separated linka>li>
                        <li role="separator" class="divider">li>
                        <li><a href="#">One more separated linka>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="#">Actiona>li>
                        <li><a href="#">Another actiona>li>
                        <li><a href="#">Something else herea>li>
                        <li role="separator" class="divider">li>
                        <li><a href="#">Separated linka>li>
                    ul>
                li>
            ul>
        div>
    div>
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 Nameth>
              <th>Last Nameth>
              <th>Usernameth>
            tr>
          thead>
          <tbody>
            <tr>
              <th scope="row">1th>
              <td>Marktd>
              <td>Ottotd>
              <td>@mdotd>
            tr>
            <tr>
              <th scope="row">2th>
              <td>Jacobtd>
              <td>Thorntontd>
              <td>@fattd>
            tr>
            <tr>
              <th scope="row">3th>
              <td>Larrytd>
              <td>the Birdtd>
              <td>@twittertd>
            tr>
          tbody>
    table>
div>

body>
html>

BootStrap使用笔记+案例_第14张图片

7.图标

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

​ 下载

​ 引入

"stylesheet" href="plugins/font-awesome-4.7.0/css/font-awesome.css">
DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Titletitle>
    <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">
        
        <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 navigationspan>
                <span class="icon-bar">span>
                <span class="icon-bar">span>
                <span class="icon-bar">span>
            button>
            <a class="navbar-brand" href="#">商城a>
        div>

        
        <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="#">Actiona>li>
                        <li><a href="#">Another actiona>li>
                        <li><a href="#">Something else herea>li>
                        <li role="separator" class="divider">li>
                        <li><a href="#">Separated linka>li>
                        <li role="separator" class="divider">li>
                        <li><a href="#">One more separated linka>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="#">Actiona>li>
                        <li><a href="#">Another actiona>li>
                        <li><a href="#">Something else herea>li>
                        <li role="separator" class="divider">li>
                        <li><a href="#">Separated linka>li>
                    ul>
                li>
            ul>
        div>
    div>
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 Nameth>
              <th>Last Nameth>
              <th>Usernameth>
            tr>
          thead>
          <tbody>
            <tr>
              <th scope="row">1th>
              <td>Marktd>
              <td>Ottotd>
              <td>@mdotd>
            tr>
            <tr>
              <th scope="row">2th>
              <td>Jacobtd>
              <td>Thorntontd>
              <td>@fattd>
            tr>
            <tr>
              <th scope="row">3th>
              <td>Larrytd>
              <td>the Birdtd>
              <td>@twittertd>
            tr>
          tbody>
    table>
div>

body>
html>

BootStrap使用笔记+案例_第15张图片

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>Titletitle>
        <link rel="stylesheet" href="plugins/bootstrap-3.4.1-dist/css/bootstrap.css">
        <link rel="">
    head>
    <body>
    
    <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
      Launch demo modal
    button>
    
    
    <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">×span>button>
            <h4 class="modal-title" id="myModalLabel">Modal titleh4>
          div>
          <div class="modal-body">
            ...
          div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Closebutton>
            <button type="button" class="btn btn-primary">Save changesbutton>
          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使用笔记+案例_第16张图片

你可能感兴趣的:(前端,bootstrap,前端)