P粉6337331462023-08-15 12:43:02
I think I know where the problem is. The animation doesn't work because the background-position property is set to fixed. This means that the background image will not move, regardless of animation. To solve this problem, you need to change the background-position property to scroll.
body { background-color: black; margin: 0; padding: 0; background-image: url("我有一个正确的URL,但我不想分享它"); background-size: cover; background-repeat: no-repeat; background-attachment: scroll; animation: slide 1s linear infinite alternate; } @keyframes slide { 0% { background-position: -175% 0%; } 100% { background-position: 300% 0%; } } .container { max-width: 800px; margin: 0 auto; padding: 0px; }