html - 背景图像 :no-repeat not working, 语法正确

标签 html css

下面是我用于背景图像的语法。由于某种原因,它在 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/

相关文章:

html - 如何应用 CSS 将标签中包裹的 DDA.AC 字符置于屏幕中央

jquery - 使用 Bootstrap 按钮和下拉元素的自定义选择标签行为

javascript - Angular 6 - 无法在 Canvas 上动态添加文本

html - CSS 多行内多个 div 的间距

html - 有没有办法在Google Analytics(分析)上隐藏我的引荐来源网站

php - 数据库结果以内联和分配的 block 的相反顺序显示

javascript - 将 'positive' 样式应用于百分比(如果为正)- 从 Google 表格中提取

javascript - 同时选择changin

html - 使用flex实现两行一列布局

html - element[attr=value] 选择器不起作用