Bootstrap学习(一)

一、准备所有资源

1、首先需要下载Bootstrap
这里写图片描述

2、下载jquery
这里写图片描述

二、代码部分:
1、根据设备显示页面的比例

<!--加了这句话就会实现响应式布局-->
    <meta name="viewport" content="width=device-width,initial-scale= 1" >

initial-scale为缩放比例

2、引入文件

//引入样式
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">
//引入jquery
<script src="bootstrap/js/jquery.min.js"></script>
//js
<script src="bootstrap/js/bootstrap.min.js"></script>

3、布局样式

<!--布局样式
container 固定宽度并且具有响应式
container-fluid自由宽高(100%)
-->
<div class="container">
    <h1>Downloading jQuery</h1>
   <p> Compressed and uncompressed copies of jQuery files are available. The uncompressed file is best used during development or debugging; the compressed file saves bandwidth and improves performance in production. You can also download a sourcemap file for use when debugging with a compressed file. The map file is not required for users to run jQuery, it just improves the developer's debugger experience. As of jQuery 1.11.0/2.1.0 the //# sourceMappingURL comment is not included in the compressed file.

    To locally download these files, right-click the link and select "Save as..." from the menu.
   </p>
</div>

<div class="container-fluid">
    <h1>Downloading jQuery</h1>
     <font class="h1">行内块样式</font>
    <p> Compressed and uncompressed copies of jQuery files are available. The uncompressed file is best used during development or debugging; the compressed file saves bandwidth and improves performance in production. You can also download a sourcemap file for use when debugging with a compressed file. The map file is not required for users to run jQuery, it just improves the developer's debugger experience. As of jQuery 1.11.0/2.1.0 the //# sourceMappingURL comment is not included in the compressed file.

        To locally download these files, right-click the link and select "Save as..." from the menu.
    </p>
</div>
  • 表格样式
<body style="padding: 50px;background-color: #ccc">
<div class="container" style="background-color: #fff;padding: 50px;">
    <h1> 表格 </h1>
    <table class="table">
        <tr>
            <td>编号</td>
            <td>新闻标题</td>
            <td>发布者</td>
            <td>发布时间</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
    </table>
</div>
</body>

效果图:
这里写图片描述

表格的其他样式

  • 表格隔行变色
//表格隔行变色
<table class="table table-striped">

效果图:
这里写图片描述

  • 表格边框
//表格边框
<table class="table table-striped table-bordered">

效果图:
这里写图片描述

  • 表格鼠标放上或离开效果
<table class="table table-hover table-condensed">
  • 表格的自动滚动条
<!--当屏幕大小小于768时出现滚动条-->
    <div class="table-responsive">
    <table class="table table-hover table-condensed">
        <tr class="active">
            <td>编号</td>
            <td>新闻标题</td>
            <td>发布者</td>
            <td>发布时间</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
    </table>
    </div>
  • 表格的样式
<!--form-inline 是表格横向排列-->
    <form class="form-inline">
        <div class="form-group">
            <!--sr-only 设置隐藏-->
            <label for="username" class="sr-only">用户名:</label>
            <input type="text" class="form-control" id="username" placeholder="请输入您用户名">
        </div>
        <div class="form-group">
            <label for="password">密码:</label>
            <input type="text" class="form-control" id="password" placeholder="请输入您的密码">
        </div>
    </form>

Bootstrap 的基本的 HTML 模板:

<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap 模板</title>
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <!-- 引入 Bootstrap -->
      <link href="http://apps.bdimg.com/libs/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">

         <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
         <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
      <![endif]-->
   </head>
   <body>
      <h1>Hello, world!</h1>

      <!-- jQuery (Bootstrap 的 JavaScript 插件需要引入 jQuery) -->
      <script src="https://code.jquery.com/jquery.js"></script>
      <!-- 包括所有已编译的插件 -->
      <script src="js/bootstrap.min.js"></script>
   </body>
</html>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Bootstrap是一个开源的前端框架,由Twitter的设计师和工程师共同开发。它提供了一系列的CSS、JavaScript和HTML组件,可用于快速搭建现代化的响应式网站和Web应用程序。 学习Bootstrap可以帮助你更高效地开发Web应用程序,减少开发时间和成本。以下是一些学习Bootstrap的步骤: 1. 了解Bootstrap的基础知识:Bootstrap提供了一系列的CSS类和JavaScript插件,用于快速搭建响应式布局、表单、导航条等组件。你可以先了解Bootstrap的基础知识,包括网格系统、排版、颜色、图标等。 2. 阅读Bootstrap文档:Bootstrap官方文档提供了详细的说明和示例,可以帮助你更好地理解Bootstrap的用法和功能。你可以按照文档的顺序逐步学习Bootstrap的各个组件和插件,从而掌握其使用方法。 3. 实践Bootstrap的应用:通过实践应用,你可以更深入地理解Bootstrap的用法和功能。你可以从简单的网站布局开始,逐步尝试使用Bootstrap的各个组件和插件,例如导航条、表单、模态框等。 4. 学习Bootstrap的扩展库:Bootstrap有许多扩展库,例如Bootstrap Material Design、BootstrapVue等,可以进一步扩展Bootstrap的功能和应用范围。你可以学习这些扩展库,并尝试将其应用到你的项目中。 5. 查阅Bootstrap的案例:Bootstrap已经被广泛应用于各种类型的Web应用程序,你可以查阅一些Bootstrap的案例,例如Bootstrap官方网站、Bootstrap Expo等,了解Bootstrap在实际项目中的应用和优化方法。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值