Stop jQuery cycle from setting display:none;

笑着哭i 提交于 2019-12-09 18:40:45

问题


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.

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.

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'
});

Thanks!


回答1:


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.



来源:https://stackoverflow.com/questions/7390192/stop-jquery-cycle-from-setting-displaynone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!