首页 > 解决方案 > Background-repeat-x/y 在 Firefox/Safari 中不起作用

问题描述

我下面的代码演示了background-repeat-x/y由于某种原因在 FireFox 上不起作用。它只是删除了这些样式(但不像它们不正确+它们没有在某处被覆盖)。当我尝试将这些样式组合在一个 ( background) 中时,它也会脱颖而出。可以理解为什么会发生这种情况。没找到类似的。

.myDiv {
  height: 200px;
  background-image: url(https://user-images.githubusercontent.com/37912316/38108463-2d5980dc-3395-11e8-948a-d7fd97647f86.png);
  background-repeat-x: no-repeat;
  background-repeat-y: repeat;
  
}
<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    
    <body>
        <div class="myDiv">
        <p>Some text</p>
        </div>
    </body>
</html>

标签: cssfirefox

解决方案


改为使用background-repeat: repeat-y;

background-repeat-x: no-repeat;
background-repeat-y: repeat;

在文档中找不到。


推荐阅读