每當背景圖像變化時,我需要它來覆蓋身體。我使用的是background-size: cover
,但它似乎不起作用。background-size:cover;財產
body {
position: relative;
margin-top: 60px;
background-color: #000;
font-family: 'Roboto Slab', serif;
background: url(https://i.ytimg.com/vi/lECC6eQhnZo/maxresdefault.jpg);
background-repeat: no-repeat;
background-position: center center;
background-atachment: fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
transition: background 1s;
和這裏的jQuery的改變所述圖像:
$("body").css("background", objects[newNum].img);
的圖像被存儲在一個陣列(對象)。
CodePen:http://codepen.io/Chantun/pen/WxXaGy?editors=0010
謝謝!這很簡單。 – Chantun