首页 > 其他分享 >JQuery animate 动画研究汇总

JQuery animate 动画研究汇总

时间:2022-11-11 11:36:36浏览次数:33  
标签:JQuery 动画 function click var animate document div


JQuery animate 动画研究汇总_animate

JQuery animate 动画研究汇总_asp.net_02

JQuery animate 动画研究汇总_animate_03

JQuery animate 动画研究汇总_animate_04

JQuery animate 动画研究汇总_动画_05

jquery.color.js要放在juqery-1.8.3.js这个核心库的下面:

JQuery animate 动画研究汇总_jquery_06

JQuery animate 动画研究汇总_jquery_07

.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"><</div>
<div id="div_right">></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 动画研究汇总_jquery_08

标签:JQuery,动画,function,click,var,animate,document,div
From: https://blog.51cto.com/u_15866446/5843749

相关文章

  • aps.net--自动图片移动模块( JQuery animate)
    .aspx代码如下:<%@PageTitle=""Language="C#"MasterPageFile="~/SAMPLE_CODE/AMST_SAMPLE.master"AutoEventWireup="true"CodeFile="S2_JAnimate_ImgMove.aspx.cs"Inh......
  • intent跳转时添加动画效果实例
    系统默认的intent跳转效果非常生硬,丑陋,影响用户体验,怎么添加跳转动画呢?首先新建两个动画文件:zoomin.xml:<?xmlversion="1.0"encoding="utf-8"?><setxmlns:android="htt......
  • jquery.toast提示框案例
    <!doctypehtml><htmllang="zh"><head><metacharset="utf-8"><title>JQuery信息提示框插件jquery.toast.js的使用</tit......
  • SVG动画之AnimatedVectorDrawable学习以及使用
    LZ-Says:伙计,一路走来,走散了一些人,留下了最真的人,切勿悲伤,切勿心寒。抬起头,微笑继续向前行~前言上一篇,我们了解了SVG以及静态Vector图像使用,坐标地址如下:​​AndroidStudy......
  • iOS开发_UITableViewCell动画
    -(void)tableView:(UITableView*)tableViewwillDisplayCell:(UITableViewCell*)cellforRowAtIndexPath:(NSIndexPath*)indexPath{cell.transform=CGA......
  • jQuery-tmpl 模板引擎使用方法说明
    jQuery-tmpl的几种常用标签分别有:${}{{each}}{{if}}{{else}}{{html}}不常用标签是:{{=}}{{tmpl}}{{wrap}}1、${}和{{=}}${}等同于{{=}},输出变量,${}里面还可以放表达式(=和......
  • Web前端--Jquery获取域名的更目录
    jquery取得文件根目录functiongetRootPath(){//获得根目录varstrFullPath=window.document.location.href;varstrPath=window.document.location.pa......
  • simpread-(128 条消息) 【three.js 学习笔记(1)】读取 blender 模型并导入动画_orangecs
    本文由简悦SimpRead转码,原文地址blog.csdn.net之前尝试过使用vtk.js在浏览器上绘制三维图形。其与VTKC++版接口类似,上手较快,但vtk.js相对更新较慢,接口功能不完善......
  • jQuery实现无刷新切换主题皮肤功能
    参考一主题皮肤切换功能在很多网站和系统中应用,用户可以根据此功能设置自己喜欢的主题颜色风格,增强了用户体验。本文将围绕如何使用jQuery实现点击无刷新切换主题皮肤功能......
  • 利用snowfall.jquery.js实现满屏爱心表白代码
    利用snowfall.jquery.js实现满屏爱心表白代码一、效果展示二、代码分析第一步:利用伪元素before和:after画两个重叠在一起的长方形,如图所示:<!DOCTYPEhtml><html><head>......