Bootstrap-概述


v4.3模板为:
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  </head>
  <body>
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
  </body>
</html>

文件引入

除了 bootstrap.js bootstrap.css 外,还需要导入依赖js文件 popper.js jQuery.js

移动端优先

bootstrap优先移动端设备,为了确保适当的绘制和触屏缩放,需要添加viewport元标记:

<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

还可以添加user-scalable=no禁止用户缩放来使网站更像原生应用,但这并不适合所有网站,要视情况而定。

参数 解释
width=device-width 等于设备宽度
initial-scale=1 初始化缩放比例为1(即不缩放)
shrink-to-fit=no 关闭自适应宽度,兼容IOS
minimum-scale 最小缩放比例
maximum-scale 最大缩放比例
user-scalable 是否允许用户缩放(和最小/大缩放比例冲突,只需设置一种)

增强跨浏览器性

为了增强跨浏览器表现的一致性,我们使用了 Normalize.css,这是由 Nicolas Gallagher 和 Jonathan Neal 维护的一个CSS 重置样式库。

该css文件中重新定义了各个html标签的样式,使得不同设备的表现具有一致性

猜你喜欢

转载自www.cnblogs.com/yangjiale/p/11441504.html