ege动画,jquery使用percenteges进行动画制作

Is there any way i can animate a div using percentages with jquery?

I've tried these:

$('.box1').animate({width:($(".wrapper").width()*.100)},"fast");})

$('.box1').animate({width:'100%'},"fast");})

$('.box1').animate({width:100%;})

none of the above work...

any ideas?

UPDATE

var p_e_h= 1.0;

var p_e_w= 1.0;

$('.box1').animate({width:($(".wrapper").width()* p_e_w)},"fast");

$('.box1').animate({height:($(".wrapper").height()* p_e_h)},"fast");

width works, but height does not. Unless i click the button again.

解决方案var fiftyPrct = 0.5, //50%

hundredPrct = 1; //100%

$('.box1').animate({ width: ($('.wrapper').width() * fiftyPrct) }, 'fast');

$('.box2').animate({ width: ($('.wrapper').width() * hundredPrct) }, 'fast');

Should work fine.

Update

Since you are doing 2 different .animate calls, the animations are queued and executed sequentially. Just do them with the same animation call:

var p_e_h= 1.0;

var p_e_w= 1.0;

$('.box1').animate({

width: ($(".wrapper").width() * p_e_w),

height:($(".wrapper").height() * p_e_h)

},"fast");

Example of it working: jsFiddle

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
```c #include <graphics.h> #include <conio.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <windows.h> #define MAXSIZE 1000 void get_next(char *p, int *next) { int i = 0, j = -1; next[0] = -1; while (i < strlen(p)) { if (j == -1 || p[i] == p[j]) { i++; j++; next[i] = j; } else { j = next[j]; } } } int kmp(char *s, char *p, int *next) { int i = 0, j = 0; while (i < strlen(s) && j < strlen(p)) { if (j == -1 || s[i] == p[j]) { i++; j++; } else { j = next[j]; } } if (j == strlen(p)) { return i - j; } else { return -1; } } int main() { char s[MAXSIZE], p[MAXSIZE]; int next[MAXSIZE]; initgraph(640, 480); setbkcolor(WHITE); cleardevice(); settextcolor(BLACK); settextstyle(20, 0, "宋体"); outtextxy(10, 10, "请输入主串:"); outtextxy(10, 50, "请输入模式串:"); settextstyle(16, 0, "宋体"); rectangle(150, 5, 630, 35); rectangle(150, 45, 630, 75); while (kbhit()) getch(); while (1) { if (kbhit()) { char c = getch(); if (c == '\r') { break; } else if (c == '\b') { if (strlen(s) > 0) { s[strlen(s) - 1] = '\0'; rectangle(150, 5, 630, 35); outtextxy(150, 10, s); } } else { if (strlen(s) < MAXSIZE - 1) { s[strlen(s)] = c; s[strlen(s) + 1] = '\0'; rectangle(150, 5, 630, 35); outtextxy(150, 10, s); } } } } while (kbhit()) getch(); while (1) { if (kbhit()) { char c = getch(); if (c == '\r') { break; } else if (c == '\b') { if (strlen(p) > 0) { p[strlen(p) - 1] = '\0'; rectangle(150, 45, 630, 75); outtextxy(150, 50, p); } } else { if (strlen(p) < MAXSIZE - 1) { p[strlen(p)] = c; p[strlen(p) + 1] = '\0'; rectangle(150, 45, 630, 75); outtextxy(150, 50, p); } } } } get_next(p, next); int pos = kmp(s, p, next); if (pos != -1) { settextstyle(20, 0, "宋体"); outtextxy(10, 100, "匹配成功!"); settextstyle(16, 0, "宋体"); char tmp[MAXSIZE]; strncpy(tmp, s, pos); tmp[pos] = '\0'; outtextxy(10, 150, tmp); settextcolor(RED); strncpy(tmp, s + pos, strlen(p)); tmp[strlen(p)] = '\0'; outtextxy(10 + pos * 10, 150, tmp); settextcolor(BLACK); strncpy(tmp, s + pos + strlen(p), strlen(s) - pos - strlen(p)); tmp[strlen(s) - pos - strlen(p)] = '\0'; outtextxy(10 + (pos + strlen(p)) * 10, 150, tmp); } else { settextstyle(20, 0, "宋体"); outtextxy(10, 100, "匹配失败!"); } while (!kbhit()) { Sleep(100); } closegraph(); return 0; } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值