Chrome devtools reporting the same CSS on the same line twice

限于喜欢 提交于 2019-12-01 14:50:26

问题


Chrome DevTools is reporting the same CSS on the same line twice. Is anyone else seeing this? How can I fix it?

The problem occurs in both stable (40) and Canary (42)

style.css is being loaded exactly once. It is not minified.


回答1:


There's a few options here:

You may have included the stylesheet twice

If that is not the case (you're not using preprocessors or minification) I suspect have you included two references to the same file. Use view source for this - in the network tab they would appear as the same file.

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test</title>
    <link rel="stylesheet" href="test.css" />
    <link rel="stylesheet" href="test.css" />
</head>
<body>
    <h2 class="title">Title</h2>
</body>
</html>

CSS

h2.title {font-size: 30pt; color: #24a222; }

Result

You may have declared h2.title twice on the same line.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test</title>
    <style>
        h2.title {font-size: 30pt; color: #24a222; }h2.title {font-size: 30pt; color: #24a222; }
    </style>
</head>
<body>
    <h2 class="title">Title</h2>
</body>
</html>



来源:https://stackoverflow.com/questions/28364838/chrome-devtools-reporting-the-same-css-on-the-same-line-twice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!