When performing document.getElementById('bilder').style.background=
you are not only overriding the css property background
but also the sub properites, i.e. background-size
. You do not redefine background-size
, so this will be set back to default (auto
).
I would use document.getElementById('bilder').style.backgroundImage
instead, so you are not overriding the other sub properties. http://jsfiddle.net/8m7VB/3/