简体   繁体   English

在Google Chrome中调试CSS

[英]Debugging CSS in Google Chrome

I am writing some CSS files, but when I make a mistake, Chrome appears to just silently ignore the parts that I screw up, and renders the rest. 我正在写一些CSS文件,但是当我犯了一个错误时,Chrome似乎只是默默地忽略了我搞砸的部分,然后渲染剩下的部分。

This makes it annoying to debug since I can't figure out what is going wrong. 这使得调试很烦人,因为我无法弄清楚出了什么问题。

So, is there a way to get Chrome to "scream at me in big red letters," so that I can spend less time finding the error and more time fixing it? 那么,有没有办法让Chrome“用大红色字母尖叫我”,这样我就可以花更少的时间找到错误并花更多的时间修复它?

While you can not "debug" CSS, because it is not a scripting language, you can utilize the Chrome DevTools Elements panel to inspect an element & view the Styles pane on the right. 虽然您无法“调试”CSS,因为它不是脚本语言,您可以使用Chrome DevTools Elements面板检查元素并查看右侧的“样式”窗格。 This will give you insights as to the styles being overridden or ignored (line threw). 这将为您提供有关被覆盖或忽略的样式的见解(投掷线)。 The Styles pane is also useful because of it's ability to LiveEdit the document being inspected, which may help you iron out the issues. “样式”窗格也很有用,因为它能够对正在检查的文档进行LiveEdit,这可以帮助您解决问题。 If the styles are being overridden, you can then view the Computed Style pane to see the CSS that is actually being utilized to style your document. 如果正在覆盖样式,则可以查看“计算样式”窗格以查看实际用于设置文档样式的CSS。

To bring up the Chrome DevTools window, hit Ctrl + Shift + I in a Chrome browser tab. 要打开Chrome DevTools窗口,请在Chrome浏览器标签中按Ctrl + Shift + I. ( Command + Opt + I for a mac) Command + Opt + I for a mac)

For more info visit https://developer.chrome.com/devtools/index 有关详细信息,请访问https://developer.chrome.com/devtools/index

As CSS is not a scripting language, you cant properly debug it. 由于CSS不是脚本语言,因此无法正确调试它。 Anyway if you know where it goes wrong you can try to tune it by hand. 无论如何,如果你知道哪里出了问题,你可以尝试手动调整它。

Aditionally you've got the w3c validator here: http://jigsaw.w3.org/css-validator/ which may give you some feedback 另外你在这里有w3c验证器: http//jigsaw.w3.org/css-validator/可能会给你一些反馈

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM