更多詳情,您應該將背景設置爲colonna_sx,而不是身體。因此,將此添加到colonna_sx。
background-repeat: no-repeat;
background-position: center;
background-size: cover;
然後你應該改變腳本。如果你添加jQuery,你可以改變它。
document.body.background ='http://adventureofucm.com/OtherSites/image_background/'+num+'.jpg';
這個。
var backgroundpic = 'http://adventureofucm.com/OtherSites/image_background/'+num+'.jpg';
$('.colonna_sx').css("background", "url(backgroundpic)");
沒有jQuery。
document.querySelector('div.colonna_sx').style.backgroundImage = 'url(http://adventureofucm.com/OtherSites/image_background/' + num + '.jpg)';
這應該適用於大多數瀏覽器(IE8以上)http://caniuse.com/#feat=queryselector。
你的jsfiddle演示充滿了空:)你沒有保存小提琴。 – 2014-09-01 07:47:19
赦免,應該修正:D – 2014-09-01 07:48:22
你能否更準確地解釋你想要的,我不明白。你想讓左列中的背景成爲該列的中心? – dashtinejad 2014-09-01 07:59:16