CSS 什么是解析错误以及如何修复它

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14111733/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 21:09:25  来源:igfitidea点击:

what is a parse error and how do I fix it

cssvalidation

提问by user1940007

I am having trouble with my site, www.jeremyspence.net78.net there are supposed to be five different color spaces, and there is only three, so I tried using a css validator and it said there is a parse error on the parts of the css I am having trouble with, but I don't understand what is wrong with it and why it isn't working here is the validator http://jigsaw.w3.org/css-validator/validator?uri=www.jeremyspence.net78.net&profile=css3&usermedium=all&warning=1&vextwarning=&lang=enand here is the css

我的网站 www.jeremyspence.net78.net 有问题,应该有五种不同的颜色空间,而只有三种,所以我尝试使用 css 验证器,它说部分有解析错误我遇到问题的 css,但我不明白它有什么问题,为什么它在这里不起作用是验证器http://jigsaw.w3.org/css-validator/validator?uri=www。 jeremyspence.net78.net&profile=css3&usermedium=all&warning=1&vextwarning=&lang=en这是css

#mecontainer {
? ? width: 100%;
? ? height: 1080px;
? ? padding-top:50px;
? ? background: #cecefe;
}
#supportcontainer {
? ? width: 100%;
? ? height: 1080px;
? ? padding-top:50px;
? ? background: #fecefe;
}

回答by cimmanon

You have some sort of invisible character that the validator is choking on somewhere (ie. it looks and acts like a space, but it isn't the space). If I view your CSS file directly and copy/paste the contents into the CSS validator's direct input validation, it validates.

你有某种无形的特征,验证器在某处窒息(即它看起来和行为像一个空间,但它不是空间)。如果我直接查看您的 CSS 文件并将内容复制/粘贴到 CSS 验证器的直接输入验证中,它就会进行验证。

回答by Jukka K. Korpela

The problem characters in http://www.jeremyspence.net78.net/css/general.csscan be analyzed using Rex Swain's HTTP Viewerusing the Display Format option “Hex”. It can then be seen that they are hex A0. The character encoding does not seem to be declared anywhere, so browsers (and validators) have to guess. If UTF-8 is implied, A0 is a data error at character level. If ISO-8859-1 or windows-1252 is implied, it stands for NO-BREAK SPACE, which is not allowed in CSS.

http://www.jeremyspence.net78.net/css/general.css 中的问题字符可以使用 Rex Swain 的HTTP Viewer使用 Display Format 选项“Hex”进行分析。然后可以看出它们是十六进制A0。字符编码似乎没有在任何地方声明,因此浏览器(和验证器)必须猜测。如果隐含 UTF-8,则 A0 是字符级别的数据错误。如果隐含 ISO-8859-1 或 windows-1252,则它代表 NO-BREAK SPACE,这在 CSS 中是不允许的。

The origin of the problem is probably in some authoring program that has converted a normal SPACE to a NO-BREAK SPACE. It looks like a space, walks like a space, quacks like a space, but it still isn't a space, in CSS parsing. So you need to edit the CSS file and replace the offending indentations by simple spaces.

问题的根源可能在于某些已将正常空间转换为无中断空间的创作程序。在CSS解析中,它看起来像一个空间,走起来像一个空间,嘎嘎叫起来像一个空间,但它仍然不是一个空间。所以你需要编辑 CSS 文件并用简单的空格替换有问题的缩进。