下面是我用于背景图像的语法。由于某种原因,它在 Y 上重复。我不能使用 overflow:hidden;
<style>
body {
background-image: url('<?php echo $ActualPath; ?>images/backgroundimage.jpg');
background-image: no-repeat;
}
</style>
我希望背景图像在 x 和 y 上不重复。
最佳答案
你应该使用的语法是
background-image: url(path/images/backgroundimage.jpg);
background-repeat: no-repeat;
.. 或者
background: url(path/images/backgroundimage.jpg) no-repeat;
如果您更喜欢 short-hand syntax .
background-image
总是只定义一个图像文件,因此在您的示例中,第二个 background-image
规则试图覆盖第一个规则,但由于“没有-repeat"不是有效的图像文件,浏览器会忽略它。
列出了各种背景属性here供引用。
关于html - 背景图像 :no-repeat not working, 语法正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11109013/