html引用bootstrap的方法:1、使用“link rel”方式在线引用bootstrap;2、将Bootstrap下载到本地,并将需要的文件放在项目下,然后在相应文件中引入即可。
Bootstrap的引入
Bootstrap的使用一般有两种方法:
引用在线的Bootstrap的样式,
将Bootstrap下载到本地进行引用。
在线引用
基本模板如下:
Bootstrap引入优点:不用本地安装Bootstrap,也不用考虑引用时的路径问题
缺点:一旦在线样式挂了,那么会影响整个页面样式的呈现
本地引用
将Bootstrap下载到本地。
直接访问上述代码中的3个网址来获取代码
去Bootstrap的官网 http://v3.bootcss.com/ 和JQuery
的官网 http://jquery.com/ 下载相应的文件
将需要的文件放在项目下,便于引用
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.css、js/bootstrap.min.js
jquery.min.js可以在JQuery官网下载
最后,在相应文件中引入即可。
优点:确保网络状况不佳的情况下,页面样式依然可以正常显示
缺点:需要提前安装或下载,引用时要考虑路径问题。