我们可以淡入和淡入iframes [英] Can we do fade in and fade out in iframes

查看:121
本文介绍了我们可以淡入和淡入iframes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能使iframe中的淡入和淡出转换成功? 解决方案

淡入或淡出可以通过一个非常简单的例子:

  var iframe = document.getElementById('iframe'); 

fadeOut(iframe,1000);

函数fadeOut(el,duration){

/ *
* @param el - 要淡出的元素。
* @param duration - 动画持续时间,以毫秒为单位。
* /

var step = 10 /持续时间,
opacity = 1;
函数next(){
if(opacity< = 0){return; }
el.style.opacity =(opacity - = step);
setTimeout(next,10);
}
next();

$ / code>






jQuery是一个令人难以置信的图书馆你的使用应该不仅仅是它创造奇特效果的能力。应该采用图书馆的完整性和易用性;不是因为它恰好提供了您可能想要使用的一种一种的东西。

Is it possible to make fade in and fade out transitions in iframes?

解决方案

Fading in or out can be achieved by changing the opacity of an element over time, a very simple example:

var iframe = document.getElementById('iframe');

fadeOut(iframe, 1000);

function fadeOut(el, duration) {

    /*
     * @param el - The element to be faded out.
     * @param duration - Animation duration in milliseconds.
     */

    var step = 10 / duration,
        opacity = 1;
    function next() {
        if (opacity <= 0) { return; }
        el.style.opacity = ( opacity -= step );
        setTimeout(next, 10);
    }
    next();
}


While jQuery is an incredible library your usage of it should be justified by more than just its ability to create fancy effects. A library should be adopted for its completeness and ease of use; not because it happens to offer just one thing you might want to use.

这篇关于我们可以淡入和淡入iframes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆