如何制作推拉门效果?

MyH*_*rts 4 jquery

我希望有一个推拉门效果,用户点击一个链接,一扇门落在当前内容上,然后显示新内容.Chris Carey在原型中做到了这一点,但我想使用jquery.有插件或教程吗?我看到了一个,但它非常基本.

原型示例

use*_*716 5

这是一个帮助您入门的基本示例:

试试看: http ://jsfiddle.net/yuF8S/3/ (更新切换内容)

JS

$('a').click(function() {
    var index = $(this).index();
    $('#door').animate({top:0}, 500, function() {
        $('#content > .contentItem').hide()
            .eq(index).show();
        $(this).animate({top: -200}, 500);
    });
});
Run Code Online (Sandbox Code Playgroud)

HTML

<div id='container'>
    <div id='content'>
        <div class='contentItem'>content display 1</div>
        <div class='contentItem'>content display 2</div>
        <div class='contentItem'>content display 3</div>
    </div>
    <div id='door'></div>
</div>

<div id='links'>
    <a href='#'>content 1</a>
    <a href='#'>content 2</a>
    <a href='#'>content 3</a>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS

#container {
    float:left;
    width: 200px;
    height: 300px;
    clip: auto;
    overflow: hidden;
    position: relative;
}
#content {
    width: 100%;
    height: 200px;
    background: yellow;
    position: absolute;
    bottom: 0;
}
.contentItem {
    display:none;
}
.contentItem:first-child {
    display:block;
}
#door {
    width: 100%;
    height: 100%;
    position: absolute;
    top: -200px;
    background: black;
}
#links {
    float: left;
} 
a {
    display: block;
}
Run Code Online (Sandbox Code Playgroud)