jquery - 在 HTML CSS 标记中声明的背景图像之间的过渡

标签 jquery css

我可以改变我的背景图片:

 $('html').css({background : 'url(http://www.cyberth.com/images/background_aporia.jpg)'});

如何在两个图像之间进行淡出和淡入过渡。如果可以避免的话,我不想为此在 Body 中使用 div。

这样的事情似乎不起作用:

 $('html').not('body').fadeOut("slow");

即使我将 html 的 z 索引更改为 1 并将 body 更改为 2,设置 html 标签的不透明度也会向下级联。

我在 css 中的背景声明如下所示:

 html { 
     background: url(http://www.cyberth.com/images/background_odonata.jpg) 
     no-repeat center center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;

最佳答案

您不能将背景应用到 html,而是应用到具有 100% 宽度和高度以及负 z-index 的绝对位置的 div。然后你应该能够在不影响其他任何东西的情况下对那个 div 做任何事情。然后你甚至可以为此使用像 jquery cycle 这样的插件。 http://jquery.malsup.com/cycle/

关于jquery - 在 HTML CSS 标记中声明的背景图像之间的过渡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8049606/

相关文章:

javascript - 动画循环 - css

javascript - 从绝对位置 div 算起的图像高度

javascript - 如何在 jQuery Mobile 中的按钮上添加渐变悬停

css - 右边先显示后弹出框下移

javascript - 如何将 id ="getdobval"插入输入值?

javascript - jQuery 对象 `toString()` 方法

javascript - 从另一个 HTML/CSS 文件实现代码的方法?

javascript - 将 d3.selection.classed() 与来自数据的类值一起使用

php - &lt;!--[if lte IE8]>< ![endif]--> 出现在网站和下拉问题上

html - 如何右对齐李?