我正在尝试创建一个页面,当你点击按钮时可以更改背景图片。代码笔:http://codepen.io/meek/pen/EPLZpW
body {
background: url('https://s3.eu-central-1.amazonaws.com/meek-img/1.jpg') no-repeat center center fixed;
background-size: cover;
-webkit-transition: background .5s ease-in-out;
-moz-transition: background .5s ease-in-out;
-o-transition: background .5s ease-in-out;
transition: background .5s ease-in-out;
}
我当前的做法存在两个主要问题:
- 在Mozilla Firefox中根本无法工作。
- 动画效果不流畅。它会瞬间切换到一个空白背景,然后再运行动画。有没有办法避免这种情况,或者由于加载时间而不可避免?如果有其他方法来实现这个功能而避免这个问题该怎么做?起初,我想使用jQuery进行动画处理,但被告知这并不是最佳选择。