美文网首页我爱编程
Bootstrap的引入

Bootstrap的引入

作者: 杨慧莉 | 来源:发表于2017-02-27 10:13 被阅读0次

    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官网下载
    最后,在相应文件中引入即可。
    优点:确保网络状况不佳的情况下,页面样式依然可以正常显示
    缺点:需要提前安装或下载,引用时要考虑路径问题。

    相关文章

      网友评论

        本文标题:Bootstrap的引入

        本文链接:https://www.haomeiwen.com/subject/cruawttx.html