2D Scrolling Background with any resolution

Hey, I am asking for help regarding the scrolling background issue that i had when developing a game.I wanted to make an infinite scrolling background in my game however i realized that it is difficult to adjust the offset in my code to suit the entire screen. Is there an easier way to do this? I seek your help, thank you : )

the background could be on the canvas, if that is what you mean, that way it will stay in the same place on your screen, however if you want a sort of parallax on the background i’m not sure how to do that