跳到主要內容

jQuery, animate function with css exlapenation.

Today, I want to use jQuery making a animation for webpage, First I check animate fuction on ref book. I clearly know how use it, there are two main function for animate.

1.
$().animate({"style1":"value1", "style2":"value2"}, Time);

Time: it can be three type, String => "slow", "fast", "normal". Integer=>10000

2.
$().stop();

it can immedaitely stop animation.

Let's do some experieces, I bulit a simple page. You can hover UP and DOWN for a article sliding UP or DOWN. Les't do it.

HTML CODE:
<div id="all">
<div id="up">往上</div>
<div id="showTab">

<div id="data">
About

This script is intended for forms where the user needs to upload an image to a Web site.

The image is displayed on the page for previewing before uploading. The display will be resized if needed so as not to break the page layout. Valid file types are set in the script; others will be disallowed.

live demo : http://hedgerwow.appspot.com/image-upload-preview/demo.html

download source : http://code.google.com/p/image-upload-preview/source/browse/#svn/trunk
Comments

http://code.google.com/p/image-upload-preview/wiki/CommentsWall
Screenshot

</div>

</div>
<div id="down">往下</div>
</div>

CSS CODE:

<style type="text/css">
<!--
#showTab {
height: 150px;
width: 250px;
overflow:hidden;
position:relative;
}
#showTab #data{
position:relative;
}
#up, #down{
height:20px;
border:1px #00CC33 solid;
text-align:center;
background:#999999;
}
#all{
background:#FFFFFF;
border:1px #660066 solid;
overflow:hidden;
}
-->
</style>

jQuery CODE:


<script type="text/javascript">
$(document).ready(function(){
var divDataHeight = $('#showTab').height() +100;

$('#data').css('position','relative');
$('#showTab').css('position','relative');
$('#down').hover(function(){
$('#data').animate({top: 0}, 3000);
},
function(){
$('#data').stop();
});


$('#up').hover(function(){
$('#data').animate({top: -divDataHeight}, 3000);
},
function(){
$('#data').stop();
}
);


});


</script>


It is done. You can post these codes on your webpage, of course before you excute have to load jQeury.js .

NOTE:
if you want animate your div, your div layer css style have to set "position:relative".
You can try more effects by yourself, example "opacity", "height"....
If you have anything new about animate, please let me know. Thank you for yor reading.

留言

  1. How to make money from betting on football - Work Tomake Money
    If you're having problems jancasino finding 출장샵 a winning bet งานออนไลน์ online for the day of your choosing, then 바카라 사이트 there are plenty of opportunities available right 토토 사이트 here.

    回覆刪除

張貼留言

這個網誌中的熱門文章

[分享] 腳踏車環島注意事項

很多人都期望自己能夠做點什麼,做些什麼,而退伍之後的第二個星期,就展開了環島之旅。 對很多人來說這不算什麼,甚至有人展開了走路、跑步、溜滑板、單輪車等方式環島一周,充分展現對台灣的愛與關懷。 這篇主要讓不知道怎麼準備環島的人,作一個完善的解說,首先隨身的東西要有: 證件現金類 : 身份證 健保卡 學生證 現金 提款卡 悠遊卡

[解釋] uuid 與 guid 的差異

uuid 與 guid 的差異 很多人都有使用過 MySQL 的 number auto increment, 可是實際使用之後就會發現,很快的數字會不夠使用,而且這個 id 是很容易被猜測出來連續性。 因此就開始進行了解,看到了 uuid 這個名詞,進而下去查詢發現 guid 的另外這個名詞,感覺上這兩個名詞似乎是有些什麼特殊關連。 這篇文章就小小記錄一下自己的查詢心得。

[教學] 快快樂樂刪除CodeIgniter index.php

預設的CI網址預設都設定為index.php同一層級,因此所有的程式都必須指定index.php導向才能開始,例如 http://localhost/ci/index.php/welcome/test http://localhost/ci/welcome/test 本文將說明如何將惱人的index.php消除,還你一個漂亮的URL。 設定開始: 接下來說明如何使用rewrite方式將惱人的index.php去除。 rewrite不清楚的人,煩請先自行google 首先要先確定Apache的 mod_rewrite 有 開啟 ,如果沒有開啟請設定好之後重新啟動apache。 接著,在根目錄底下建立一個新檔案,檔名為 .htaccess ,裡面程式碼如下: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] </IfModule> 接著到 application/config/config.php ,開啟檔案修改 $config['index_page'] = ""; 注意: /index.php/$1 要根據你目錄,例如 http://localhost/index.php ,網站根目錄為 /ci/index.php 則要寫成 /ci/index.php/$1 接著至CI目錄下,尋找 config\config.php , 修改一下裡面的檔案,修改如下: $config['index_page'] = ""; 存檔後,如此一來大功告成。 參考資料 官方網站說明