错误:CSS:背景:/是不正确的运算符 [英] Error: CSS: background: / is an incorrect operator
问题描述
我有以下HTML:
<!DOCTYPE html>< html lang ="zh-CN">< head>< title> test</title></head><身体>< div style ="height:100%; background:url('https://apprecs.org/ios/images/app-icons/256/90/1097333136.jpg')100%0不重复/4%;>< p>鲍勃是这最好的!</p></div></body></html>
图像显示效果很好,但是当我转到
/
是 background-position
和 background-size
(此为可选)之间的分隔,因此正确的语法为:
背景:url(...)100%0/4%不重复;
其中 background-position:100%0
和 background-size:4%
请注意,在使用速记语法时,应始终使用 background-position
指定 background-size
.您不能指定没有位置的尺寸,但是可以指定没有尺寸的位置:
背景:url(...)100%0不重复;
相关问题:问题的背景位置"在背景"中速记属性
I have the following HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<title>test</title>
</head>
<body>
<div style="height:100%;background: url('https://apprecs.org/ios/images/app-icons/256/90/1097333136.jpg') 100% 0 no-repeat / 4%;">
<p>
bob
Is
The
best!
</p>
</div>
</body>
</html>
The image displays well but when I go to the HTML validator I get an error:
Error: CSS: background: / is an incorrect operator.
If I remove that /
then the image doesn't appear. What is the correct way?
If we refer to the formal syntax:
The /
is the separation between background-position
and background-size
(this one being optional) so the correct syntax is:
background: url(...) 100% 0/4% no-repeat;
Where background-position:100% 0
and background-size:4%
Note that background-size
should always be specified with background-position
when using shorthand syntax. You cannot specify the size without position but you can specify position without size:
background: url(...) 100% 0 no-repeat;
Relatad question: Issues with "background-position" in "background" shorthand property
这篇关于错误:CSS:背景:/是不正确的运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!