[英]CSS Invalid Property Value?
I don't understand what's wrong with this?我不明白这有什么问题? I'm watching a tutorial and it seems to work fine on the video but both mozilla and chrome ignore this code and marks it as an invalid property value.
我正在看一个教程,它似乎在视频上运行良好,但 mozilla 和 chrome 都忽略了此代码并将其标记为无效的属性值。
.btn {
background-color: #4FB69F url("img/texture.png") no-repeat right top;
}
change改变
background-color:
to到
background:
Because background
is a shorthand property for因为
background
是一个速记属性
Another possible cause could be that you have a "Hidden Character" in the css property or value.另一个可能的原因可能是您的 css 属性或值中有一个“隐藏字符” 。
To fix that, copy the code directly from you IDE to some "Hidden Character" detector like this one https://www.soscisurvey.de/tools/view-chars.php ,delete the 'bad' characters and then save your code again without the bad characters.要解决此问题,请将代码直接从您的 IDE 复制到一些“隐藏字符”检测器,例如https://www.soscisurvey.de/tools/view-chars.php ,删除“坏”字符,然后保存您的代码再次没有坏字符。
Bonus: If you are using a JetBrains ide like WebStorm, this plugin can help you https://plugins.jetbrains.com/plugin/7448-zero-width-characters-locator奖励:如果您使用像 WebStorm 这样的 JetBrains ide,这个插件可以帮助您https://plugins.jetbrains.com/plugin/7448-zero-width-characters-locator
If you are using inverted commas in your css.
Please remove inverted commas from your css file.
For Example,
Please find below css and find difference between both css
.row{
margin-left:'-16px !important';
margin-right:'0px !important';
}
.row{
margin-left:-16px !important;
margin-right:0px !important;
}
background-color: #4FB69F;
background-image: url('images/texture.png');
background-repeat: no-repeat;
background-position: right top;
Within the image url requires ' not " Background position is separate from no repeat and ; between each element control图像url内要求'非'背景位置是分开的,没有重复和;在每个元素控件之间
Instead of writing:而不是写:
.btn {
background-color: #ffffff;
background-image: url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;
}
You can use the shorthand property background:您可以使用速记属性背景:
.btn {
background: #ffffff url("img_tree.png") no-repeat right top;
}
It does not matter if one of the property values is missing, as long as the other ones are in this order.缺少一个属性值无关紧要,只要其他属性值按此顺序即可。 know more
了解更多
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.