I need the background image to have more content that will remain in the center of the content but not affect the layout (this means no scroll bars to fit the background image). Content should be centered using margin: auto; so that the left side will remain flush with the left side of the viewing area when the viewing area becomes smaller than the content.
I asked this question several times and tried quite a few solutions, but none of the accepted answers worked.
Edit to clarify
This question is still a little murky, so I will try to clarify some of the images showing what I need. In these images, green is the background image, red is the main content, and blue is the browser view pane.
A:. When the viewing area is smaller than the background image and the main content, the left part of the content remains flush with the left side of the viewing area, the background image remains centered to the main content, scroll bars in the sheets will scroll only to the right edge of the main content (and not to the right edge of the background).
B: When the viewport is larger than the background image and content, they remain centered in the viewport.
C: If the viewport is the same size as the main content, the background image should remain in the center of the main content, no scrollbars should be present.
source share