To understand what's going on here, you need to understand two things: CSS specificity and CSS background- properties.
1: CSS Specificity
The primary problem you are having here is that using .style=[something] in Javascript will write your new styles to the HTML style="[something]" attribute. It does not overwrite the browser's cached version of the CSS, and therefore, all rules pertaining to the property you are changing are simply ignored and not overwritten.
CSS also reads rules in order, from least specific to most specific, from top to bottom. Every time it finds a new rule for an existing property, it disregards the old one and uses the new one.
With that in mind, let's take a look at:
2: Background- Properties
In CSS, there are multiple properties that handle background, such as:
background:
background-size:
background-position:
- etc.
Each of these properties will only affect ONE property of the background settings; the exception to this rule is the catch-all background: property.
By setting the background: property, you overwrite ALL background settings, including ones you don't specify. Now in your CSS, you have written other background- properties after that catch-all background: property. Those will cause CSS to ignore the specific rules you set in the catch-all property.
BUT!
When you set the .style to use the background: property, you are inserting a whole new set of CSS rules that are more specific than the previous ones. This means that CSS will read this new property last, and since it is the catch-all, it will ignore ALL of the previous rules you just set up; in particular, it is ignoring your background-size property.
To fix this, make sure that you set each of these individually and do not use the catch-all property.
E.g. use background-image, background-repeat, and background-position instead of background:.
document.getElementById("myDiv").style.backgroundImage = "url(/img/someImage.jpg)";
You can use the background: property, but it will require you to re-set all of the other background- properties that you set in the original CSS via Javascript.