Chrome devtools在同一行上报告同一个CSS两次 [英] Chrome devtools reporting the same CSS on the same line twice

查看:119
本文介绍了Chrome devtools在同一行上报告同一个CSS两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Chrome DevTools在同一行上报两次相同的CSS。还有其他人看到这个吗?



这个问题发生在stable(40)和canary(42)



style.css 正在加载一次。



解决方案

您可能已在同一行上声明了h2.title两次。

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



如果不是这样(你不使用预处理器或缩小),我怀疑你包含了两个引用文件。



HTML


$ b $ b

 <!DOCTYPE html> 
< html lang =en>
< head>
< meta charset =UTF-8>
< title> Test< / title>
< link rel =stylesheethref =test.css/>
< link rel =stylesheethref =test.css/>
< / head>
< body>
< h2 class =title>标题< / h2>
< / body>
< / html>



CSS



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



结果




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.

解决方案

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>

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

这篇关于Chrome devtools在同一行上报告同一个CSS两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆