zoukankan      html  css  js  c++  java
  • jquery左右自适应伸缩插件

    简单css布局

    body {
        margin: 0 auto;
        padding: 0 auto;
    }
    .showpannal {
        position:absolute;
        left: 200px;
        top:300px;
    }
    .pannal_left {
        width: 200px;
        height: 670px;
        background-color: #6CF;
        float: left;
    }
    .pannal_right {
        height: 670px;
        margin-left: 200px;
        background-color: #CFF
    }

    jquery自定义函数

    shrink = function () {
            var show = '<div id="pannal_left" class="pannal_left"></div><div id="pannal_right" class="pannal_right"></div><span id="animate" style="z-index:999;cursor:pointer;"><img src="leftbar.png" width="15" height="53"  alt=""/></span> </div>';
            return ep = {
                init: function (obj) {
                    ep.create(obj);
                    ep.bindEvent(obj);
                },
                create: function (obj) {
                    obj.append(show);
    				obj.find("span").addClass("showpannal");
                },
                bindEvent: function (obj) {
                    obj.toggle(function () {
                        $("#pannal_left").animate({  "0px" });
                        $("#pannal_right").animate({ marginLeft: "0px" });
                        obj.find("span").animate({ left: "0px" });
                    }, function () {
                        $("#pannal_left").animate({  "200px" });
                        $("#pannal_right").animate({ marginLeft: "200px" });
                        obj.find("span").animate({ left: "200px" });
                    });
                }
            };
        }
    	
    
        $.fn.bindanimate = function () {
    		var me=new shrink();
            return this.each(function () {
                me.init($(this));
            });
        }
    

     

    调用事例

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>无标题文档</title>
    </head>
    <link rel="stylesheet" type="text/css" href="animate.css">
    <script src="jquery-1.8.0.min.js"></script>
    <script src="animate.js"></script>
    <body>
    <div id="animate" style="100%;height:670px;">
    </div>
    </body>
    </html>
    <script type="text/javascript">
    $(function () {
    	$("#animate").bindanimate();
    });
    </script>
    

      

     展示效果

  • 相关阅读:
    [置顶] 当今世界最受人们重视的十大经典算法
    Android入门:调用WebService
    Android入门:实现一个File存储的辅助类
    多线程下载辅助类实现
    在Java程序中设置代理
    配置EditPlus使其可以编译运行java程序
    Android入门:文件上传
    Resource is out of sync with the file system
    【入门算法】思维导图
    sharepoint2010 重建服务器场的方法
  • 原文地址:https://www.cnblogs.com/f23wangj/p/4268326.html
Copyright © 2011-2022 走看看