若希望 body 的背景圖片置中且不重複,可用以下寫法。
html, body { width: 100%; height: 100%; } body { background: #fff url(/eg/eg_2014_01_02_14_50.jpg) center no-repeat; }
關鍵是 center 與 no-repeat。若希望背景能填滿整個視窗,還需讓 html 與 body 撐滿高度。
center
no-repeat