首页 文章

外部CSS在Safari中运行良好,但在Firefox,Google Chrome或Opera中无效

提问于
浏览
-1

所以我有一个简单的html文件,其中包含3个外部css文件 .

<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <title>some website</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="stylesheet" type="style/css" href="style/reset.css" charset="utf-8"/>
    <link rel="stylesheet" type="style/css" href="style/shared.css" />
    <link rel="stylesheet" type="style/css" href="style/home.css" />
    <!--[if lt IE 9]>
        <script src="scripts/html5shiv.js" type="text/javascript"></script>
    <[end if]-->
</head>
<body>
</body>
</html>

这些css文件在Safari中工作正常,但Firefox和谷歌浏览器都无法识别所有三个css文件 . Opera中的同样问题 .

我已经仔细检查了文件路径,在适当的地方添加了charset =“utf-8”,并尝试清理缓存,删除了我的用户帐户库中的所有相关文件,并重新安装了两个浏览器 . 仍然是同一个问题 .

我正在使用macOS 10.13.4(17E202)在Mac上本地测试网站

Safari版本11.1(13605.1.33.1.4)

谷歌浏览器版本66.0.3359.139(官方版本)(64位)

Firefox版本59.0.3(64位)

Opera版本52.0.2871.99

检查员状态的一些屏幕截图 .

Firefox Style Editor shows no style sheet

Google Chrome does not list css files as well

如您所见,图像和JavaScript文件就可以了 .

我究竟做错了什么?有什么建议?

不知何故改变了与css文件相关的三行解决了这个问题 .

<link rel="stylesheet" href="style/reset.css">
<link rel="stylesheet" href="style/shared.css">
<link rel="stylesheet" href="style/home.css">

1 回答

  • 0

    type属性应该指定为 type="text/css", 你已经写了 type="style/css" 更改它并试一试并确保你的路径是正确的 . 检查您的浏览器是否有任何404错误 .

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

    Link For Reference

相关问题