zoukankan      html  css  js  c++  java
  • jQuery控制的不同方向的滑动(横向滑动等)

    引入jquery.js,复制以下代码,即可运行。

    Css代码  收藏代码
    1. <style type="text/css">  
    2. .slide {  
    3.     position: relative;  
    4.     height: 200;  
    5.     lightyellow;  
    6. }  
    7.   
    8. .slide .inner {  
    9.     position: absolute;  
    10.     left: 0;  
    11.     bottom: 0;  
    12.     height: 100;  
    13.     lightblue;  
    14.      100%  
    15. }  
    16. </style>  

     1、slidetoggle() 交替slidedown(),slideup()

    Html代码  收藏代码
    1. <div id="slidebottom" class="slide">  
    2.     <button>  
    3.         slide it  
    4.     </button>  
    5.     <div class="inner">  
    6.         Slide from bottom  
    7.     </div>  
    8. </div>  
    Js代码  收藏代码
    1. $('#slidebottom button').click(function() {  
    2.   $(this).next().slideToggle();  
    3. });  

    2、左侧横向交替滑动 Animate Left 

    Html代码  收藏代码
    1. <div id="slidewidth" class="slide">  
    2.     <button>  
    3.         slide it  
    4.     </button>  
    5.     <div class="inner">  
    6.         Slide from bottom  
    7.     </div>  
    8. </div>  
    Js代码  收藏代码
    1. $("#slidewidth button").click(function(){  
    2.  $(this).next().animate({ 'toggle'});  
    3. });  

     3、左侧横向交替滑动 Animate Left Margin (非隐藏)

    Html代码  收藏代码
    1. <div id="slideleft" class="slide" style=" 50%;float: right">  
    2.     <button>  
    3.         slide it  
    4.     </button>  
    5.     <div class="inner">  
    6.         Slide from bottom  
    7.     </div>  
    8. </div>  
    Js代码  收藏代码
    1. $("#slideleft button").click(function(){  
    2.  var $lefty = $(this).next();  
    3.  $lefty.animate({  
    4.   left:parseInt($lefty.css('left'),10)==0 ? -$lefty.outerWidth() : 0  
    5.  });  
    6. });  
     

    4、右侧横向滑动Slide to right

    Html代码  收藏代码
    1. <div id="slidemarginleft" class="slide" style=" 60%;float: left">  
    2.     <button>  
    3.         slide it  
    4.     </button>  
    5.     <div class="inner">  
    6.         Slide from bottom  
    7.     </div>  
    8. </div>  

      

    Js代码  收藏代码
    1. $("#slidemarginleft button").click(function(){  
    2.  var $marginlefty = $(this).next();  
    3.  $marginlefty.animate({  
    4.   marginLeft:parseInt($marginlefty.css('marginLeft'),10)==0 ? $marginlefty.outerWidth() : 0  
    5.  });  
    6. });  
     
     
  • 相关阅读:
    UML类图学习总结
    Java和C# RSA加解密相互通信和使用公钥加密传输
    C#des加密算法指定键的大小对于此算法无效
    WCF--找不到具有绑定 BasicHttpBinding 的终结点的与方案 https 匹配的基址。注册的基址方案是 [http]。
    IIS7 使用server farms 进行负载均衡
    iis7 未注册framework4 导致 莫名的404错误
    启用代理导致 有道云笔记未知错误、网络错误和OneDrive断线
    AspNetCore发布到Centos7
    c# 操作临时数据---XML操作
    c# 获取程序目录
  • 原文地址:https://www.cnblogs.com/xiaochao12345/p/3848486.html
Copyright © 2011-2022 走看看