读书人

仿照万智牌卡牌效果

发布时间: 2012-08-09 15:59:21 作者: rapoo

模仿万智牌卡牌效果

css

var Cards = (function () {            var _fun = {                bindHover: function (o, z_indexMax) {                    o.hover(function () {                        var _o = $(this);                        var i = z_indexMax;                        var j = 0;                        _o.stop();                        _o.animate({ "height": "150px" }, 500)                        while (i--) {                            if (i > _o.index()) {                                o.eq(i).css("z-index", j);                            } else if (i < _o.index()) {                                o.eq(i).css("z-index", _o.index() - j);                            }                            else {                                o.eq(i).css("z-index", z_indexMax);                            }                            j++;                        }                    }, function () {                        var _o = $(this);                        _o.stop();                        _o.animate({ "width": "220px", "height": "99px" }, 200)                    })                },                init: function (containerKey) {                    var fun = _fun,                    obj = $(containerKey),                    li = obj.find("li");                    li.css({ "position": "absolute", "width": "220px", "height": "99px", "overflow": "hidden", "border": "1px solid red" });                    var i = 0;                    li.each(function () {                        var _o = $(this);                        _o.css({ "margin-left": i * 20 + "px", "z-index": i });                        i++;                    })                    fun.bindHover(li, i--);                }            }            return {                Init: _fun.init            }        })()        Cards.Init("#div_Container");


读书人网 >Web前端

热点推荐