从设置display:none停止jQuery循环; [英] Stop jQuery cycle from setting display:none;

查看:70
本文介绍了从设置display:none停止jQuery循环;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个小游戏,用户从一组项目中进行选择,然后对所选项目进行洗牌并选择一个。

I'm creating a little game where a user selects from a set of items then the selected items are shuffled and one is chosen.

我正在使用jQuery循环( http://jquery.malsup.com/cycle/ )运行主动画并选择一个随机项目(使用随机顺序功能和自定义动画)。

I'm using jQuery cycle (http://jquery.malsup.com/cycle/) to run the main animation and select a random item (using the random order feature and a custom animation).

然而,我动画项目的方式意味着我需要它们才能保持可见状态'动画 - 它们都绝对定位。

However, the way I'm animating the items means I need them to all remain visible while they're animating - they're all positioned absolutely.

所以这里的问题是:
有没有办法阻止jQuery循环应用 显示:无; 开始之前的所有项目?

So here's the question: Is there a way to stop jQuery cycle from applying display: none; to all of the items before it starts?

如果有必要,我不介意修改原始脚本。

I don't mind modifying the original script to do this if necessary.

$('#item-container').cycle({ 
    fx: 'custom',
    cssBefore:{
        left: 0,
        top: 0,
        display: 'block',
        zIndex: 1
    },
    animIn: {
        left: 200,
        top: 200
    },
    animOut: {
        left: 0,
        top: 0
    },
        cssAfter:{
        zIndex: -40,
        display: 'block'
    },
    speed:  400,
    timeout: 400,
    random: 1,
    autostop: 1,
    autostopCount: 25,
    continuous: 1,
    slideExpr: 'div.selected'
});

谢谢!

推荐答案

尝试在CSS中添加!important。通常,内联css(例如,类似于循环插件设置的内容)将覆盖样式表中的css。但是,如果你使用!important,那将优先。

Try adding !important in your CSS. Normally, inline css (for instance, like that set by the cycle plugin) will override css in your stylesheet. However, if you use !important, that will take precedence.

这篇关于从设置display:none停止jQuery循环;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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