弄清 CSS3 的 transition 和 animation

弄清 CSS3 的 transition 和 animation
原文:弄清 CSS3 的 transition 和 animation

弄清 CSS3 的 transition 和 animation

transition

transition 屬性是
transition-property,
transition-duration,
transition-timing-function,
transition-delay
的簡稱,用于設定一個元素的兩個狀態,不同的狀態可以用偽類,比如:hover, :active 或者是通過 javascript 動態設定。IE10+支持。

所以 transition 的初始值為:

transition-delay: 0s;
transition-duration: 0s;
transition-property: all;
transition-timing-function: ease;

用法

div {transition: <property> <duration>    <timing-function> <delay>;
}

并且有事件可以監測 transition 結束

el.addEventListener("transitionend",updateTransition,true);//in webkit
el.addEventListener("webkitTransitionEnd",updateTransition,true);

實例

HTML

<!--  DEMO 1: Fade Block -->
<div id="fade">move here  !
</div><div id="nudge">mouse on me 
</div><div id="bounce">Place mouse on  me i will bounce!</div><div id="spin">Place mouse on  me i won  me i won  me i won  me i won  me i won  me i won  me i won  me i won  me i won  me i won  me i won  me i won  me i won  me i won  me i will spin</div><div id="accordion" class="accordion"><a href="#first">This is first tab</a><div id="first"><p>Lorem ipsum </p> </div><a href="#second">This is second tab</a><div id="second"><p>Lorem ipsum </p> </div><a href="#third">This is third tab</a><div id="third"><p>Lorem ipsum </p> </div>
</div>

CSS

/*
DEMO 1: Fade Block
*/
div {margin-bottom: 50px;
}#fade {/*opacity:1;-webkit-transition: opacity 10s liner 10s;*/position: relative;transition-property: font-size;transition-duration: 0.5s;transition-delay: 0;font-size: 14px;
}#fade:hover {font-size: 36px;
}/* DEMO2 */
#nudge{-webkit-transition-property: color,background-color,padding-left;-webkit-transition-duration: 500ms,500ms, 500ms;
}#nudge:hover{background-color: #efefef;color: #333;padding-left: 50px;
}#bounce:hover {-webkit-animation-name:bounce;-webkit-animation-duration:1s;-webkit-animation-iteration-count:2;-webkit-animation-direction:alternate
}
@-webkit-keyframes bounce {from{margin-left:0;}to{margin-left:250px;}
}#spin{-webkit-transition: -webkit-transform 10s ease-in;
}#spin:hover{-webkit-transform: rotate(36000deg);
}.accordion a{display: block;padding:5px 10px;background-color:#ccc;color:#000;/*可以去掉鏈接的下劃線等修飾效果*/text-decoration:none;}
.accordion a:hover{background-color:#999;
}
.accordion div{background-color:#cda;color:#222;
}
.accordion div p{padding:20px
}#accordion div{/*先隱藏起來*/height:0;overflow:hidden;-webkit-transition:height 600ms ease;
}#accordion div:target{height:110px;
}

animation

animation 屬性是如下這些屬性的簡寫
animation-name: none
animation-duration: 0s
animation-timing-function: ease
animation-delay: 0s
animation-iteration-count: 1
animation-direction: normal
animation-fill-mode: none

用法

animation:animation-nametime(duration)timing-functiontime(delay)animation-iteration-count( 結束之前的循環次數)single-animation-direction /*{animation-direction: normal (每次從正方向開始)animation-direction: reverse (每次從反方向開始)animation-direction: alternate (正反往復)}*/single-animation-fill-mode

實例

<div class="view_port"><div class="polling_message">Listener for dispatches     </div><div class="cylon_eye"></div>
</div>
.polling_message {color: white;float: left;margin-right:2%;
}
.view_port {background-color: black;height: 50px;width: 100%;overflow: hidden;
}
.cylon_eye {color: white;height: 100%;width: 80%;background-color: red;background-image: linear-gradient(to right, rgba(0, 0, 0, 0.9) 25%, rgba(0, 0, 0, 0.1) 50%, rgba(0, 0, 0, 0.9) 75%);-webkit-animation: move_eye 4s linear 0s infinite alternate;-moz-animation: move_eye 4s linear 0s infinite alternate;-o-animation: move_eye 4s linear 0s infinite alternate;animation: move_eye 4s linear 0s infinite alternate;
}
@-webkit-keyframes move_eye {from {margin-left:-20%;}to {margin-left:100%;}
}
@-moz-keyframes move_eye {from {margin-left:-20%;}to {margin-left:100%;}
}
@-o-keyframes move_eye {from {margin-left:-20%;}to {margin-left:100%;}
}
@keyframes move_eye {from {margin-left:-20%;}to {margin-left:100%;}
}
posted on 2014-08-12 09:25 NET未來之路 閱讀(...) 評論(...) 編輯 收藏

轉載于:https://www.cnblogs.com/lonelyxmas/p/3906520.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/258297.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/258297.shtml
英文地址,請注明出處:http://en.pswp.cn/news/258297.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

【SVM】簡單介紹(二)

1、SVM另一種推法 我們不管分類平面&#xff0c;直接去假設Margin的兩個邊界&#xff1a; Plus-plane {x:w?xb1}Minus-plane {x:w?xb?1}\begin{aligned} & \text { Plus-plane }\{\boldsymbol{x}: \boldsymbol{w} \cdot \boldsymbol{x}b1\} \\ & \text { Minus-plan…

圖像像素點賦值_Python 圖像處理 OpenCV (2):像素處理與 Numpy 操作以及 Matplotlib 顯示圖像...

普通操作1. 讀取像素讀取像素可以通過行坐標和列坐標來進行訪問&#xff0c;灰度圖像直接返回灰度值&#xff0c;彩色圖像則返回B、G、R三個分量。需要注意的是&#xff0c; OpenCV 讀取圖像是 BGR 存儲顯示。灰度圖片讀取操作&#xff1a;import cv2 as cv# 灰度圖像讀取gray_…

cocopods

一、什么是CocoaPods 1、為什么需要CocoaPods 在進行iOS開發的時候&#xff0c;總免不了使用第三方的開源庫&#xff0c;比如SBJson、AFNetworking、Reachability等等。使用這些庫的時候通常需要&#xff1a; 下載開源庫的源代碼并引入工程向工程中添加開源庫使用到的framework…

CSS3學習手記(10) 過渡

CSS3過渡 允許css的屬性值在一定的時間內平滑地過渡在鼠標單擊、獲取焦點、被點擊或對元素任何改變中觸發&#xff0c;并圓滑地以動畫效果改變CSS的屬性值transition transition-property屬性檢索或設置對象中的參與過渡的屬性 語法 transition-property:none|all|property …

POJ 1286 Necklaces of Beads (Burnside定理,有限制型)

題目鏈接&#xff1a;http://vjudge.net/problem/viewProblem.action?id11117 就是利用每種等價情形算出置換節之后算組合數 #include <stdio.h> #include <cstring> #include <cstdlib> #include <algorithm> #include <cmath>using namespace…

全局搜索快捷鍵_Windows 自帶的聚合搜索來了,與 Mac 的 Spotlight 相比體驗如何?...

最近 Windows 10 推出了自帶的聚合搜索功能 PowerToys Run&#xff0c;取代了之前的 WinR。蘋果的 macOS 以人性化著稱&#xff0c;有幾個功能讓 Windows 用戶一直很羨慕&#xff0c;比如全局的聚合搜索工具 Spotlight。在任何界面 command空格&#xff0c;輸入關鍵字就能搜索電…

transform你不知道的那些事

transform是諸多css3新特性中最打動我的&#xff0c;因為它讓方方正正的box module變得真實了。 transform通過一組函數實現了對盒子大小、位置、角度的2D或者3D變換。不過很長時間內&#xff0c;我對以下問題都想不太明白&#xff1a; 1、尺寸縮放scale與zoom變換有何不同&…

【SVM】簡單介紹(三)

我們考慮SVM的對偶問題&#xff0c;我們通常是在對偶空間中進行求解的。 1、Lagrange Multipliers 對于一個很一般的問題 Minimize f(x)subject to {a(x)≥0b(x)≤0c(x)0\begin{aligned} \text { Minimize } & f(x) \\ \text { subject to } \quad & \left\{\begin{a…

玩轉iOS開發:NSURLSession講解(三)

文章分享至我的個人技術博客: https://cainluo.github.io/14986211698053.html 前言 雖然前面兩講都是說了NSURLSession的一些理論上的知識, 但我們現在起碼對NSURLSession有個大概的了解, 并不會像一開始的那樣, 一臉懵逼的看著, 這個請求是什么鬼, 那個方法是什么鬼, Task是什…

輕松搞定面試中的二叉樹題目

版權全部&#xff0c;轉載請注明出處&#xff0c;謝謝&#xff01;http://blog.csdn.net/walkinginthewind/article/details/7518888 樹是一種比較重要的數據結構&#xff0c;尤其是二叉樹。二叉樹是一種特殊的樹&#xff0c;在二叉樹中每一個節點最多有兩個子節點&#xff0c;…

李倩星r語言實戰_《基于R的統計分析與數據挖掘》教學大綱

《基于R的統計分析與數據挖掘》課程教學大綱課程代碼&#xff1a;090542009課程英文名稱&#xff1a;R Language and Data Mining課程總學時&#xff1a;32講課&#xff1a;32實驗&#xff1a;0上機&#xff1a;0適用專業&#xff1a;應用統計學大綱編寫(修訂)時間&#xff1a;…

自動化測試小結

最近差不多一年從事自動化的測試工作&#xff0c;從開始對自動化一點都不了解到現在能從實現用例、手動命令行執行用例、自制工具來執行用例&#xff0c;感覺進步還是有的。 自動化測試對于手動測試應該是有不小的優勢的&#xff0c;雖然在自動化的用例實現中剛開始的時候會顯得…

python地理可視化_【Python教程】地理可視化之二

Basemap是Matplotlib的一個子包&#xff0c;負責地圖繪制。昨天的推送對如何繪制風向圖進行了描述&#xff0c;本文再次利用該包簡單介紹如何繪制海洋及海冰溫度彩色圖示&#xff0c;該圖常見于NOAA官網。具體操作如下&#xff1a;導入命令1)設置工作環境并導入程序包%cd "…

尋找白板上的便簽條

問題來源&#xff1a;http://answers.opencv.org/question/162480/contour-detection-for-gray-stickers-on-white-background/ 題目的大概意思就是這樣的白板&#xff0c;尋找上面的各種便簽條。我找到了橘色的&#xff0c;結果是這樣代碼是這樣Mat src imread("gray-st…

LeetCode Permutations

原題鏈接在這里&#xff1a;https://leetcode.com/problems/permutations/ 題目&#xff1a; Given a collection of distinct numbers, return all possible permutations. For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2]…

去除內存上的警告,避免程序崩掉

# pragma clang diagnostic push # pragma clang diagnostic ignored "-Warc-performSelector-leaks" [self performSelector:callFunc withObject:array[1]]; # pragma clang diagnostic pop 使用原理&#xff1a;將出現警告的代碼加入內存棧中轉載于:https://www.c…

opengl2 vtk 編譯_編譯和使用VTK時值得注意的點(待續)

最近的一個項目中需要使用VTK&#xff0c;于是開始了VTK的漫漫編譯之路。長篇大論的編譯步驟網上數不勝數&#xff0c;在這里不再細說&#xff0c;可自行google。這里主要說一些在編譯過程中需要注意的地方&#xff0c;以免走歪路。1、使用cmake進行第一次configure的時候需要選…

gg

轉載于:https://www.cnblogs.com/lyzuikeai/p/7091206.html

二:Go編程語言規范-類型

1.類型 布爾值&#xff0c;數值與字符串類型的實例的命名是預聲明的。 數組&#xff0c;結構&#xff0c;指針&#xff0c;函數&#xff0c;接口&#xff0c;切片&#xff0c;映射和信道這些復合類型可由類型字面構造。 每個類型 T 都有一個 基本類型&#xff1a;若 T 為預聲明…

HDU 1728 逃離迷宮

這道題做的我想哭啊。。WA了將近十次了吧 一開始我用數組模擬的隊列&#xff0c;后來和老大代碼對拍&#xff0c;感覺改的是基本都一模一樣了&#xff0c;還是WA 實在沒有辦法了&#xff0c;改用queue了 題目里的x是列y是行&#xff0c;和代碼里的反過來的&#xff0c;要注意&a…