【发布时间】:2021-03-11 06:10:11
【问题描述】:
我有一个背景图像,我想从右向左连续滚动。我希望图像覆盖整个屏幕,但是当我设置background-size: cover; 时,它根本没有动画。我该如何解决这个问题?
HTML
<body>
...
</body>
CSS
body {
background-color: rgb(15, 5, 40);
background-image: url('./images/star background.png');
background-repeat: repeat;
background-position: top left;
background-size: cover;
animation: myMove 3s linear infinite;
}
@keyframes myMove {
from { background-position-x: right; }
to { background-position-x: left }
}
如果我设置background-size #px #px; 或initial 或X% Y% 那么它工作正常,但不覆盖整个屏幕?另外,这是图像:
【问题讨论】:
-
分享你的png图片
-
@TemaniAfif 我试着把图片放进去,但它是清晰背景上的白色星星,所以你甚至看不到它。
-
我们可以使背景颜色不同。我想这就是你看到它所做的
-
我已经发布了图片。
标签: html css background-position background-size