提问者:小点点

MIME 类型不匹配


我无法使用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>

共1个答案

匿名用户

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

Content-Type: "text/css"

尝试使用:

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

您正在使用什么服务器?