CSS 背景图像不显示(使用 HTML5 样板)
CSS Background Image Not Displaying ( using HTML5 Boilerplate)
使用 html5 样板文件建立网站时是否有任何原因
body {
background-image: url(../images/beach.png) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
在 css 中不会为我加载图像,但仅使用
body {
background: url(../images/beach.png) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
有效吗?
试试这个:
body {
background-image:url(../images/beach.png) center center fixed;
background-repeat:no-repeat;
// rest of your code
}
如果您正在使用 background-image
,则只能使用此 属性 来设置背景图片。不能设置属于其他属性的值。在这种情况下,您尝试为不属于 background-image
属性.
的属性设置值
如果您使用 background
属性,这是可能的,您可以使用它来设置任何 background
相关的 属性。
background-image
是只设置背景图片文件的指令。
可以使用这些指令设置其他属性:
background-color
background-image
background-repeat
background-attachment
background-position
background
只是一个 shorthand,它允许使用上面的一个或多个指令。
The background shorthand property sets all the background properties in one declaration.
我想你必须使用双引号。
背景图片:url("paper.gif");
使用 html5 样板文件建立网站时是否有任何原因
body {
background-image: url(../images/beach.png) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
在 css 中不会为我加载图像,但仅使用
body {
background: url(../images/beach.png) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
有效吗?
试试这个:
body {
background-image:url(../images/beach.png) center center fixed;
background-repeat:no-repeat;
// rest of your code
}
如果您正在使用 background-image
,则只能使用此 属性 来设置背景图片。不能设置属于其他属性的值。在这种情况下,您尝试为不属于 background-image
属性.
如果您使用 background
属性,这是可能的,您可以使用它来设置任何 background
相关的 属性。
background-image
是只设置背景图片文件的指令。
可以使用这些指令设置其他属性:
background-color
background-image
background-repeat
background-attachment
background-position
background
只是一个 shorthand,它允许使用上面的一个或多个指令。
The background shorthand property sets all the background properties in one declaration.
我想你必须使用双引号。 背景图片:url("paper.gif");