background-size is available with CSS3:
#image { background-image: url("bg.png"); background-size: auto; }
auto is the default and does not stretch the image.
You can set the width and height manually:
#image { background-size: 100% 100%; }
or
#image { background-size: 500px 300px; }
Alternative: background-size: contain and background-size: cover .
contain stretches the image so that the image is as large as possible, but completely visible inside the element, while cover stretches the image to 100% width, regardless of whether the image is cropped at the top and / or bottom.
But different browsers are not compatible when rendering the background with these keywords.
source share