【发布时间】:2016-02-15 10:55:40
【问题描述】:
通过以下与 CSS/JS 的链接,我能够成功选择除 Glyphicons 之外的所有 CSS。
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="../bootstrap-3.3.5-dist/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="../bootstrap-3.3.5-dist/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="../bootstrap-3.3.5-dist/bootstrap.min.js"></script>
项目文件夹结构:
-- bootstrap-3.3.5-dist
-- myProjectFolder -- index.html
-- aboutUs.html
-- ...html
-- ...html
我得到的却是:
然而,在将 HTML 文件移动到根目录后,一切正常,因此我在项目根目录上拥有 HTML 和引导程序。链接更改为:
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="bootstrap-3.3.5-dist/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href=".bootstrap-3.3.5-dist/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="bootstrap-3.3.5-dist/js/bootstrap.min.js"></script>
项目文件夹结构现在更改为:
-- bootstrap-3.3.5-dist
-- index.html
-- aboutUs.html
-- ...html
-- ...html
为什么会这样,有没有办法在不将 HTML 文件移动到根目录的情况下使其全部工作?
【问题讨论】:
-
每个浏览器都有这个问题吗?
-
您必须参考 相对于索引文件的引导文件。因此,如果您在项目根目录中有
bootstrap-3.3.5-dist,并且您的索引是/html/index.html,那么在您的索引中,您必须有... href="../bootstrap-3.3.5-dist/..." ... -
对不起。我在从项目中提取问题时犯了这个错误。然而,链接应该是项目中的
../../,但在问题中,你是对的,../ -
我没有在你的结构中看到你的 glyphcon 字体文件夹,这正常吗?
-
也许这就是你要找的。希望这会有所帮助。 :) 在这里查看接受的答案stackoverflow.com/questions/19608873/…
标签: html css twitter-bootstrap