每当背景图像变化时,我需要它来覆盖身体。我使用的是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