如何制作幻灯片动画?

时间:2012-02-23 18:59:04

标签: jquery css

css part

 body
{
background-color:black;
padding:0;
margin:0;
overflow:hidden;
}   
  #accordion {
   display:none;
       position:absolute;   
   left:89%;   
       margin-top:400px;
       width:174px;
   height:150px; 
   list-style:none;

  }

 #logpop
{
 display:none;
 position:absolute; 
 left:91%;   
 margin-top:400px;
 width:174px;
 height:150px; 

}


   <!-- login -->
   <div id="logpop">
     <div  class="logpop_box">
     <div class="form">
    <input class="input_box" name="email" type="text" placeholder="aaa"/><br/>
    <input class="input_box" name="pass" type="password" placeholder="*****"/>
            <br/>
    <button id="btn1">Login</button>
          </div>
         </div>
    </div>
 <!-- accordian menu-->
    <ul id="accordion">
<li>
    <a href="#" class="item popular" rel="popular"></a>
    <ul id="inchat" class="list_friends">
    <li class="ch0"><img src="img/49992_720384020_1896998575_q.jpg" /></li>
        <li class="ch1"><img src="img/48983_615523712_8495_q.jpg" /></li>
        <li class="ch2"><img src="img/41621_717814907_4472_q.jpg" /></li>
    </ul>
</li>
<li>
    <a href="#" class="item category" rel="category"></a>
    <ul id="inchannel">
        <li class="icha0"><img  src="img/41403_1434825607_37944358_q.jpg">Jae Jung</li>
        <li class="icha1"><img  src="img/48983_615523712_8495_q.jpg"></li>
        <li class="icha2"><img  src="img/41621_717814907_4472_q.jpg"></li>
    </ul>
</li>

 </ul>
              

在后台运行视频,我想从屏幕右侧到左侧进行登录框切片,当用户点击按钮时,它会滑出屏幕,手风琴菜单从屏幕向右滑动到左侧。我想知道css for login box和accordion有正确的位置(定位在右侧屏幕中间)以及如何实现Jquery来制作滑动动画效果。

2 个答案:

答案 0 :(得分:0)

jQuery提供.slideDown&amp; .slideUp用于从下到上滑动元素,反之亦然,但它不提供滑动ltr或rtl的元素。

但是this是一个简短的教程,介绍了如何使用最少的代码完成它。

答案 1 :(得分:0)

Check this fiddle

HTML

<input id="btnStart" type="button" value="Start" />
<div id="slider">Login</div>
<div id="accordion">
   <h3><a href="#">First header</a></h3>
   <div>First content</div>
   <h3><a href="#">Second header</a></h3>
   <div>Second content</div>
</div>​

CSS

body{
    overflow: hidden;
}
#slider{
    width: 100px;
    background-color: rgb(200,200,200);
    text-align: center;
    position: absolute;
    z-index: 100;
    top: 50px;
    right: -100px;
}
#accordion{
    position: absolute;
    z-index: 100;
    top: 20px;
    left: -100px;
}
input{
    padding: 3px;
}

的JavaScript

$("#accordion").accordion();
$("#btnStart").click(function(e) {
    $("#slider").animate({
        "right": "+=" + $(window).width() / 2 + "px"
    }, "1000");
});
$("#slider").click(function(e) {
    $("#slider").animate({
        "right": "-=" + $(window).width() / 2 + "px"
    }, "1000");
    $("#accordion").animate({
        "left": "+=" + $(window).width() / 2 + "px"
    }, "1000");
});​​

希望这会对你有所帮助。