JQuery animate 動畫研究匯總

來源:互聯網
上載者:User

標籤:asp.net   animate   動畫   jquery   

jquery.color.js要放在juqery-1.8.3.js這個核心庫的下面:


.aspx代碼如下:

<%@ Page Title="" Language="C#" MasterPageFile="~/SAMPLE_CODE/AMST_SAMPLE.master" AutoEventWireup="true" CodeFile="S1_JqueryAnimate_simple.aspx.cs" Inherits="SAMPLE_CODE_S1_JqueryAnimate_simple" %>


<asp:Content ID="Content1" ContentPlaceHolderID="CPH_HEAD" Runat="Server">
    <link href="../CSS/animate_simple.css" rel="stylesheet" type="text/css" />
    <script src="../Jscript/jquery-1.8.3.js" type="text/javascript"></script>
    <script src="../Jscript/jquery.color.js" type="text/javascript"></script>


    <script type ="text/javascript">
        $(document).ready(function () {




            //1. div_animatoe_001,點擊層本身,改變層的寬度到400px;
            $("#div_animate_001").click(function () {
                $(this).animate({ "width": "400px" });
            });


            //2. 點擊層本身,每次增加寬度20px;
            $("#div_animate_002").click(function () {
                $(this).animate({ width: "+=20" });
            });




            //3.   點擊層本身,同時改變高度和寬度及字型大小,一起設定
            $("#div_animate_003").click(function () {
                $(this).animate({ width: "400px", height: "40px", fontSize: "20px" });
            });




            //4. 點擊層本身,同時改變高度和寬度及字型大小,分開設定
            $("#div_animate_004").click(function () {
                $(this).animate({ width: "400px" }, 200);
                $(this).animate({ height: "40px" }, 200);
                $(this).animate({ fontSize: "20px" }, 200);
            });


            //5. 點擊層本身,更改背景色及透明度
            $("#div_animate_005").click(function () {
                $(this).animate({ backgroundColor: "green", width: "300px" }, 300);
                $(this).animate({ opacity: "0.5", color: "yellow" });


            });


            //6. 可移動的層,每次點擊向右移動30px
            $("#btn_6").click(function () {
                $("#div_animate_006").animate({ left: "0px" });
            });


            $("#div_animate_006").click(function () {
                $(this).animate({ left: "+=30px" });
            });


            //7.內層的移動控制
            $("#div_left").click(function () {
                var r = getR();
                if (r >= 80) {
                    $("#div_content").animate({ left: "-=80" });
                } else {
                    $("#div_content").animate({ right: "0" });
                }

            });


            $("#div_right").click(function () {
                var l = getL();
                if (l >= 80) {
                    $("#div_content").animate({ left: "+=80" });
                } else {
                    $("#div_content").animate({ left: "0" });
                }
            });


            
        });


//2個取值函數可以合并,請自行合并


        function getR() {
            var _w1 = document.getElementById("div_content").offsetWidth;
            var _L1 = document.getElementById("div_content").offsetLeft;
            var _w2 = document.getElementById("div_middle").offsetWidth;
            var _L2 = document.getElementById("div_middle").offsetLeft;
            return (_w1 - _w2 - _L2 + _L1);
        }

        function getL() {
            var _w1 = document.getElementById("div_content").offsetWidth;
            var _L1 = document.getElementById("div_content").offsetLeft;
            var _w2 = document.getElementById("div_middle").offsetWidth;
            var _L2 = document.getElementById("div_middle").offsetLeft;
            return ( _L2 - _L1);
        }


    </script>
    
    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CPH_MEMO" Runat="Server">
<h3>簡單動畫展示</h3>
</asp:Content>


<asp:Content ID="Content3" ContentPlaceHolderID="CPH_MAIN" Runat="Server">
    <div id="div_animate_001" class ="divAm">
        點擊層本身,改變層的寬度到400px;
    </div>


    <div id="div_animate_002" class ="divAm">
        點擊層本身,每次增加寬度20px;
    </div>


    <div id="div_animate_003" class ="divAm">
        點擊層本身,同時改變高度和寬度及字型大小
    </div>


    <div id="div_animate_004" class ="divAm">
        點擊層本身,同時改變高度和寬度及字型大小
    </div>


    <div id="div_animate_005" class ="divAm">
        點擊層本身,更改背景色及透明度
    </div>

    <div id="div_animate_006" class ="divAm">
        可移動的層,每次點擊向右移動30px
    </div>
    <input id="btn_6" type="button" value="複位層6" />


    <hr />
    內層的移動控制
    <div id="div_animate_007_outer">
    
        <div id="div_left">&lt;</div>
        <div id="div_right">&gt;</div>

        <%--middle是內容層的外框--%>
        <div id="div_middle">
            <%--content為實際內容層,實際內容可能大於外框--%>
            <div id="div_content">
                <img src="../imgs/img1.jpg" alt="" />
            </div>

        </div>

        <div style ="clear:both;"></div>

    </div>

</asp:Content>

 介面如下:


JQuery animate 動畫研究匯總

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.