【发布时间】:2016-01-28 18:32:03
【问题描述】:
我有三个不同的身体图像,并且我有一个 javascript 函数可以改变它们之间的类
function bgchange()
{
document.body.className = 'intro2';
setTimeout(bgchange2, 3000);
}
而背景不同的三个类看起来像这样
.intro {
background: url('../img/home-bg.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
-webkit-transition: background 300ms ease-in 200ms;
-moz-transition: background 300ms ease-in 200ms;
-o-transition: background 300ms ease-in 200ms;
transition: background 300ms ease-in 200ms;
}
.intro2 {
background: url('../img/home-bg2.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
-webkit-transition: background 300ms ease-in 200ms;
-moz-transition: background 300ms ease-in 200ms;
-o-transition: background 300ms ease-in 200ms;
transition: background 300ms ease-in 200ms;
}
这给了我一个淡入淡出过渡,但我想要一个向上滑动的效果而不是淡入淡出过渡,而新类 img 出现在下面,我尝试了从 css 背景位置到使用 javascript 的所有方法,但我无法弄清楚,任何帮忙?
【问题讨论】:
-
你将不得不使用动画而不是过渡。
-
你必须使用背景还是可以在 div 中使用图像!
标签: javascript html css