【问题标题】:MIME type mismatchMIME 类型不匹配
【发布时间】:2020-12-03 11:30:49
【问题描述】:

我无法用 css 解决错误:

来自“http://localhost:63342/static/style.css”的资源是 由于 MIME 类型(“text/html”)不匹配而被阻止 (X-Content-Type-Options: nosniff)。

文件夹结构为:

root
|-> content
-| index.html
|-> static
-| style.css
-| script.js

在 index.html 中我导入样式表:

<link href="../static/style.css" rel='stylesheet' type='text/css'>

但是会导致控制台出现上述错误。该错误声称我的类型是'text/html'?

我的 css 文件:

html {
    height: 100%;
}
body {
    min-height: 100%;
}

.section {
    display: none;
    margin-top:40px;
    border-top:1px solid #ccc;
}

可能有什么问题?

我以类似的方式导入 js 脚本,它工作正常:

<script type="text/javascript" src="../static/jct.js"></script>

【问题讨论】:

    标签: html css


    【解决方案1】:

    响应头应该包含“text/css”而不是“text/html”:

    Content-Type: "text/css"
    

    尝试使用:

    <link type="text/css" href="../static/style.css">
    

    你用的是什么服务器?

    【讨论】:

      猜你喜欢
      • 2020-12-17
      • 2020-06-19
      • 2012-07-10
      • 1970-01-01
      • 2013-03-14
      • 2021-04-07
      • 2013-10-05
      • 2019-09-13
      • 1970-01-01
      相关资源
      最近更新 更多