【问题标题】:Bootstrap CDN is not working when I use CDN instead of hosting remotely by using the downloaded .css file当我使用 CDN 而不是使用下载的 .css 文件进行远程托管时,引导 CDN 不起作用
【发布时间】:2026-02-10 02:15:02
【问题描述】:

CDN 加载失败,因为我在浏览器中查看时不显示样式。请调查一下,让我知道问题出在哪里,因为我很难调试。我几乎要放弃并且即将成为一个独身者。请帮忙!!!

<!DOCTYPE html>
<html lang="en">

<head>
  <title>Project</title>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>

<body>
  <div class="jumbotron">
    <h1 class="display-4">Hello, world!</h1>
    <p class="lead">This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p>
    <hr class="my-4">
    <p>It uses utility classes for typography and spacing to space content out within the larger container.</p>
    <a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a>
  </div>
</body>

</html>

【问题讨论】:

  • 您不能在 bootstrap 3 中使用 bootstrap 4 类。更多信息请参阅getbootstrap.com/docs/4.1/getting-started/introduction的快速入门
  • 该文档并没有帮助我很好地理解我的问题背后的下划线概念。
  • 请详细描述一下到底是什么问题。我认为你的代码可以运行。
  • 当我运行代码(使用 CDN)时,我得到的只是没有引导程序的基本样式。 PS:您能否向我解释一下两个版本的不同之处,因为我们所做的只是将编写好的代码粘贴到我们的文档中(除非我们想自己定制)
  • 您从 Bootstrap 4 中获取了这个示例 getbootstrap.com/docs/4.1/components/jumbotron,但是从 Bootstrap 3 中插入​​了样式表。BS3 和 BS4 之间有很多不同之处。您只需更改此行&lt;link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"&gt; 即可。

标签: html css web cdn


【解决方案1】:

我在加载 CDN 引导文件时看不到任何问题。它对我有用。请检查您的浏览器设置。

【讨论】:

  • 浏览器设置到底是什么?你能具体说明一下吗
  • 浏览器不是这里的问题。 “display-4”类或其他 BS4 类不能与 BS3 样式表一起使用。删除 BS3 样式表行并添加 BS4 样式表行。
  • " "。这些行应该可以工作,但它不是
  • 类“btn btn-primary btn-lg”适用于 BS3 和 BS4。但是例如 class="display-4" 将在 BS3 中工作。
  • 没错,但是没有规范的类无论是 3 还是 4 都无法在我的文档中加载引导样式。
【解决方案2】:

它适用于 Bootstrap 4.1.3 样式表。最好在头部添加 2 个元数据。 https://getbootstrap.com/docs/4.1/getting-started/introduction/上的文档

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Project</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
    integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>

【讨论】:

    最近更新 更多