To create a seamless, slowly moving background that loops infinitely to the right (or left, please adjust your @keyframes) along the horizontal axis, you can use the following clean and efficient CSS setup.
*Use code with caution.
A background image is cropped or cut off
When a background image appears cropped or cut off during a CSS animation, it usually happens because the browser doesn't know how to scale the image relative to the container, or the image's natural dimensions don't match the element's size.
Here is the updated CSS to fix the cropping issue while maintaining the seamless, slow horizontal scroll.
A repeating background animation isn't smooth
When a background image appears cropped or cut off during a CSS animation, it usually happens because the browser doesn't know how to scale the image relative to the container, or the image's natural dimensions don't match the element's size.
Here is the updated CSS to fix the cropping issue while maintaining the seamless, slow horizontal scroll.
A container has a fixed height
Option1: The CSS Math Fix
If you know the original dimensions of your image file, you can let CSS calculate the perfect loop point automatically using calc(). This ensures a seamless reset even if you change sizes later.
Replace ORIGINAL_WIDTH and ORIGINAL_HEIGHT in the code below with the actual pixel numbers of your raw image file:
Option 2: The Exact Pixel Fix
If you know the original dimensions of your image file, you can let CSS calculate the perfect loop point automatically using calc(). This ensures a seamless reset even if you change sizes later.
Replace ORIGINAL_WIDTH and ORIGINAL_HEIGHT in the code below with the actual pixel numbers of your raw image file: