Bootstrap的引入

Bootstrap的使用一般有两种方法:

  • 引用在线的Bootstrap的样式,
  • 将Bootstrap下载到本地进行引用。
在线引用

基本模板如下:

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Bootstrap引入</title>
    <!-- 新 Bootstrap 核心 CSS 文件 -->  
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">  
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->  
    <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>  
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->  
    <script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>  
</head>

优点:不用本地安装Bootstrap,也不用考虑引用时的路径问题
缺点:一旦在线样式挂了,那么会影响整个页面样式的呈现

本地引用
  • 将Bootstrap下载到本地。
  • 将需要的文件放在项目下,便于引用
    bootstrap的目录结构如下:
bootstrap/
├── css/
│   ├── bootstrap.css
│   ├── bootstrap.css.map
│   ├── bootstrap.min.css
│   ├── bootstrap.min.css.map
│   ├── bootstrap-theme.css
│   ├── bootstrap-theme.css.map
│   ├── bootstrap-theme.min.css
│   └── bootstrap-theme.min.css.map
├── js/
│   ├── bootstrap.js
│   └── bootstrap.min.js
└── fonts/
    ├── glyphicons-halflings-regular.eot
    ├── glyphicons-halflings-regular.svg
    ├── glyphicons-halflings-regular.ttf
    ├── glyphicons-halflings-regular.woff
    └── glyphicons-halflings-regular.woff2

最常用的是css/bootstrap.min.cssjs/bootstrap.min.js
jquery.min.js可以在JQuery官网下载
最后,在相应文件中引入即可。
优点:确保网络状况不佳的情况下,页面样式依然可以正常显示
缺点:需要提前安装或下载,引用时要考虑路径问题。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容