/ 网站根路径
./ 当前路径
../ 上一级路径
../../ 上两级路径
例如:本地静态网站 index页面地址 127.0.0.1/bootstrap_test/index.html在这里页面里面引入css和js路径应该怎么写呢?
1、
<link href="css/bootstrap.min.css" rel="stylesheet"> 实际请求地址为:127.0.0.1/bootstrap_test/css/bootstrap.min.css
找的是:和index.html 同级目录下的css文件里面的
2、
<link href="./css/bootstrap.min.css" rel="stylesheet"> 实际请求地址为:127.0.0.1/bootstrap_test/css/bootstrap.min.css
找得是:和index.html 同级里面的css文件里面的
3、
<link href="/css/bootstrap.min.css" rel="stylesheet"> 实际请求地址为:127.0.0.1/css/bootstrap.min.css
找的是根目录下面的css
4、
<link href="../bootstrap_test/css/bootstrap.min.css" rel="stylesheet"> 实际请求地址为:127.0.0.1/bootstrap_test/css/bootstrap.min.css
找得是:index.html上一级也就是和bootstrap_test处于同级里面的css文件里面的