语法错误 - JS - background.style.backgroundImage

时间:2016-10-30 15:13:10

标签: javascript html syntax

这样可以正常渲染图像。

body.style.backgroundImage = 'url(0.gif)';

这不起作用,图像根本无法渲染。

body.style.backgroundImage = 'url(0.gif) no-repeat center center fixed';

控制台中没有错误。

我在这里缺少什么?这应该有效。第二个在语法上是正确的,对吧?

1 个答案:

答案 0 :(得分:5)

请改用body.style.backgroundbody.style.backgroundImage仅适用于图片。