This is a bit complicated and requires a fixed aspect ratio of the background image.
1. Make everything responsive.
First of all, this will not work if everything is %-based , but the car is px-based (because if you change the size of your window, everything will become smaller, but the car will remain the same), so for beginners you will have to change the size of your car by a percentage .
2. Correct aspect ratio.
Then you need to correct the aspect ratio using a combination of absolute and relative positions and gaskets .
In your case, your CSS cover would look something like this:
width: 100%; padding-bottom: 71.74%;
(background image 980x1366px)
Demo
3. FUTURE PROOF: Fill the screen on each screen.
Unfortunately, you canβt do much around the white space around your image due to the aspect ratio itself, I would personally look for a 16: 9 image for the background, and it will fit most desktop / laptop screens if you need to cover a wide range screens, you should use media queries with different sized backgrounds.
Remember to customize the padding-bottom your container along with the image itself.
Hope this helps!
source share