首页 >web前端 >html教程 >Mobile Web 前端开发 CSS动画经验分享_html/css_WEB-ITnose

Mobile Web 前端开发 CSS动画经验分享_html/css_WEB-ITnose

WBOY
WBOY原创
2016-06-24 11:53:321685浏览

谈到动画作用。CSS动画是Mobilweb开发的利器,CSS动画不得不谈。受限于Mobil设备功能等疑问,PC上的动画完结计划在Mobil上大都行不通,幸运的Mobil上我能够用CSS动画,今日我就来了解一下CSS动画的3个首要成员。

CSS改换(Transit

transit默许的突变动画。当CSS特点改动的时分,界说好需求改换的CSS特点。transit动画被触发。可是并不是一切的CSS特点改动都会触发translat当前,并没有一个官方的文档列出来那些能够,那些不能够,可是能够经过一些小窍门来判别,像那些值是接连数值的特点,例如widthheighttopleftcoloropac都是能够的visibl不能够的尽管它值是数值类型的可是不是接连的

并且有很高的功能。transitiphon和Andriod平台上都能够运转。

能够经过CSS来界说transit也能够经过JavaScript来界说。运用起来十分简单。

1.界说Dom元素的transit特点(duratdelaitimefunction等)2.运用JavaScript改动Dom元素的CSS款式

如何,1.界说Dom元素的transit特点(duratdelaitimefunction等)2.运用JavaScript改动Dom元素的CSS款式

-webkit-transition-properti界说需求突变的特点-webkit-transition-dur界说动画时刻-webkit-transition-delai界说推迟时刻-webkit-transition-timing-funct界说贝赛尔曲线函数

-webkit-transition-properti能够界说详细的特点,-webkit-transition-properti界说需求突变的特点-webkit-transition-dur界说动画时刻-webkit-transition-delai界说推迟时刻-webkit-transition-timing-funct界说贝赛尔曲线函数

div.zoom-fad{-webkit-transition-property:-webkit-transform,div.zoom-fad{-webkit-transition-property:-webkit-transform,div.zoom-fad{-webkit-transition-property:-webkit-transform,opacity;-webkit-transition-duration:4s,2s;-webkit-transition-delay:2s,0;} 也能够把这些特点写在一行,

div.slid{-webkit-transition:opac500mease-out100ms;}

-webkit-transition-timing-funct能够界说动画的突变速度曲线,div.slid{-webkit-transition:opac500mease-out100ms;}

逐步慢下来,贝赛尔曲线函数为cubic-bezi0.25,eas默许。-webkit-transition-timing-funct既能够设置简称。0.1,0.25,1.0linear均速,贝赛尔曲线函数为cubic-bezi0.0,0.0,1.0,1.0ease-in渐入时加快,贝赛尔曲线函数为cubic-bezi0.42,0,1.0,1.0ease-out淡出时减速,贝赛尔曲线函数为cubic-bezi0,0,0.58,1.0ease-in-out加快然后减速,贝赛尔曲线函数为cubic-bezi0.42,0,0.58,1.0

也能够直接设置自个界说的贝赛尔曲线函数

transit完毕后会触发webkitTransitionEnd事情。能够运用addEventListen来增加事情监听器。

element.addEventListen'webkitTransitionEnd',element.addEventListen'webkitTransitionEnd',element.addEventListen'webkitTransitionEnd',functionevent{alert"Finishtransition";};

A nimat

A nimat

A nimat

A nimat

transit运用起来很简单,很便利,可是如果你想自个控制每帧的改动,那transit就不能满意你这时分你需求运用animanim有如下特点,

-webkit-animation-nam指定关键帧称号(动画的称号)-webkit-animation-dur指定多少秒或毫秒的时刻才华完结动画-webkit-animation-timing-funct指定动画的速度曲线-webkit-animation-delai推迟开端动画-webkit-animation-iteration-count播映次数;默许:1能够界说为infinit无量)-webkit-animation-direct动画方向;默许:normal

与transit不一样的anim需求界说帧,-webkit-animation-nam指定关键帧称号(动画的称号)-webkit-animation-dur指定多少秒或毫秒的时刻才华完结动画-webkit-animation-timing-funct指定动画的速度曲线-webkit-animation-delai推迟开端动画-webkit-animation-iteration-count播映次数;默许:1能够界说为infinit无量)-webkit-animation-direct动画方向;默许:normal

@-webkit-keyframsquarePath{from{top:100px;left:100px;}to{top:0px;left:0px;}

用from代表开端的帧,@-webkit-keyframsquarePath{from{top:100px;left:100px;}to{top:0px;left:0px;}

@-webkit-keyframsquarePath{from{top:0px;left:0px;}25%{top:0px;left:100px;}50%{top:100px;left:100px;}75%{top:100px;left:0px;}100%{top:0px;left:0px;}

这样我能够界说一个完好的anim

.squareA nim{-webkit-animation-name:squarePath;-webkit-animation-duration:4s;-webkit-animation-timing-function:linear;-webkit-animation-iteration-count:infinite;}

也能够选用缩写,.squareA nim{-webkit-animation-name:squarePath;-webkit-animation-duration:4s;-webkit-animation-timing-function:linear;-webkit-animation-iteration-count:infinite;}

-webkit-animation:squarePath4slinear0infinite

当我界说好anim运用JavaScript把动画设置到元素上,-webkit-animation:squarePath4slinear0infinite

anim运转的时分会触发一系列事情。

webkitA nimationStart动画开端webkitA nimationIteration动画重复履行webkitA nimationEnd动画完毕

仍然能够监听这些事情。

Transform

transform首要是改动。变换,使…变形。本身并没有突变或许动画的作用,可是transform和transit联系能够完结很漂亮很强大的作用,常用特点首要有,

transform坐标系和文档流的坐标系不一样。位移

也就是说当元素transform时分并不会影响原有文档流。rotat旋转skew歪斜scale份额translat改动。

能够运用CSS操作transform

也能够运用JavaScript操作webkitTransform特点来设置或获取transform-20pxscale2rotat45degtranslat5px.

div.style.webkitTransform='rotateY10degtranslateX10px';

经过以上办法操作的字符串,div.style.webkitTransform='rotateY10degtranslateX10px';

vartheTransform=window.getComputedStyldiv.webkitTransform;varmatrix=newWebKitCSSMatrixtheTransform;

回来的matrix不只包含矩阵特点,还包含一些办法,让我能够设置transform,vartheTransform=window.getComputedStyldiv.webkitTransform;varmatrix=newWebKitCSSMatrixtheTransform;


http://bbs.house.qq.com/t-6362718-1.htm
http://bbs.house.qq.com/t-6362741-1.htm
http://bbs.house.qq.com/t-6362762-1.htm
http://bbs.house.qq.com/t-6362796-1.htm
http://bbs.house.qq.com/t-6362813-1.htm
http://bbs.house.qq.com/t-6362829-1.htm
http://bbs.house.qq.com/t-6362853-1.htm
http://bbs.house.qq.com/t-6362882-1.htm
http://bbs.house.qq.com/t-6362911-1.htm
http://bbs.house.qq.com/t-6362928-1.htm
http://bbs.house.qq.com/t-6362948-1.htm
http://bbs.house.qq.com/t-6362976-1.htm
http://bbs.house.qq.com/t-6362993-1.htm
http://bbs.house.qq.com/t-6363008-1.htm
http://bbs.house.qq.com/t-6363024-1.htm
http://bbs.house.qq.com/t-6363054-1.htm
http://bbs.house.qq.com/t-6363074-1.htm
http://bbs.house.qq.com/t-6363089-1.htm
http://bbs.house.qq.com/t-6363107-1.htm
http://bbs.house.qq.com/t-6363122-1.htm
http://bbs.house.qq.com/t-6363137-1.htm
http://bbs.house.qq.com/t-6363154-1.htm
http://bbs.house.qq.com/t-6363177-1.htm
http://bbs.house.qq.com/t-6363201-1.htm
http://bbs.house.qq.com/t-6363219-1.htm
http://bbs.house.qq.com/t-6363236-1.htm
http://bbs.house.qq.com/t-6363255-1.htm
http://bbs.house.qq.com/t-6363288-1.htm
http://bbs.house.qq.com/t-6363304-1.htm
http://bbs.house.qq.com/t-6363323-1.htm
http://bbs.house.qq.com/t-6363336-1.htm
http://bbs.house.qq.com/t-6363377-1.htm
http://bbs.house.qq.com/t-6363403-1.htm
http://bbs.house.qq.com/t-6363428-1.htm
http://bbs.house.qq.com/t-6363448-1.htm
http://bbs.house.qq.com/t-6363462-1.htm
http://bbs.house.qq.com/t-6363489-1.htm
http://bbs.house.qq.com/t-6363508-1.htm
http://bbs.house.qq.com/t-6363542-1.htm
http://bbs.house.qq.com/t-6363563-1.htm
http://bbs.house.qq.com/t-6363596-1.htm
http://bbs.house.qq.com/t-6363618-1.htm
http://bbs.house.qq.com/t-6363635-1.htm
http://bbs.house.qq.com/t-6363657-1.htm
http://bbs.house.qq.com/t-6363681-1.htm
http://bbs.house.qq.com/t-6363716-1.htm
http://bbs.house.qq.com/t-6363744-1.htm
http://bbs.house.qq.com/t-6363764-1.htm
http://bbs.house.qq.com/t-6363782-1.htm
http://bbs.house.qq.com/t-6363798-1.htm
http://bbs.house.qq.com/t-6363828-1.htm
http://bbs.house.qq.com/t-6363858-1.htm
http://bbs.house.qq.com/t-6363893-1.htm
http://bbs.house.qq.com/t-6363916-1.htm
http://bbs.house.qq.com/t-6363947-1.htm
http://bbs.house.qq.com/t-6363966-1.htm
http://bbs.house.qq.com/t-6363994-1.htm
http://bbs.house.qq.com/t-6364097-1.htm
http://bbs.house.qq.com/t-6364120-1.htm
http://bbs.house.qq.com/t-6364206-1.htm
http://bbs.house.qq.com/t-6364225-1.htm
http://bbs.house.qq.com/t-6364241-1.htm
http://bbs.house.qq.com/t-6364254-1.htm
http://bbs.house.qq.com/t-6364271-1.htm
http://bbs.house.qq.com/t-6364302-1.htm
http://bbs.house.qq.com/t-6364370-1.htm
http://bbs.house.qq.com/t-6364384-1.htm
http://bbs.house.qq.com/t-6364402-1.htm
http://bbs.house.qq.com/t-6364419-1.htm
http://bbs.house.qq.com/t-6364432-1.htm
http://bbs.house.qq.com/t-6364445-1.htm
http://bbs.house.qq.com/t-6364464-1.htm
http://bbs.house.qq.com/t-6364490-1.htm
http://bbs.house.qq.com/t-6364505-1.htm
http://bbs.house.qq.com/t-6364521-1.htm
http://bbs.house.qq.com/t-6364546-1.htm
http://bbs.house.qq.com/t-6364571-1.htm
http://bbs.house.qq.com/t-6364599-1.htm
http://bbs.house.qq.com/t-6364653-1.htm
http://bbs.house.qq.com/t-6365164-1.htm
http://bbs.house.qq.com/t-6365189-1.htm
http://bbs.house.qq.com/t-6365227-1.htm
http://bbs.house.qq.com/t-6365245-1.htm
http://bbs.house.qq.com/t-6365262-1.htm
http://bbs.house.qq.com/t-6365299-1.htm
http://bbs.house.qq.com/t-6365332-1.htm
http://bbs.house.qq.com/t-6365358-1.htm
http://bbs.house.qq.com/t-6365383-1.htm
http://bbs.house.qq.com/t-6365401-1.htm
http://bbs.house.qq.com/t-6365423-1.htm
http://bbs.house.qq.com/t-6365445-1.htm
http://bbs.house.qq.com/t-6365487-1.htm
http://bbs.house.qq.com/t-6365503-1.htm
http://bbs.house.qq.com/t-6365519-1.htm
http://bbs.house.qq.com/t-6365540-1.htm
http://bbs.house.qq.com/t-6365567-1.htm
http://bbs.house.qq.com/t-6365595-1.htm
http://bbs.house.qq.com/t-6365629-1.htm
http://bbs.house.qq.com/t-6365702-1.htm
http://bbs.house.qq.com/t-6365722-1.htm
http://bbs.house.qq.com/t-6365746-1.htm
http://bbs.house.qq.com/t-6365766-1.htm
http://bbs.house.qq.com/t-6365794-1.htm
http://bbs.house.qq.com/t-6365816-1.htm
http://bbs.house.qq.com/t-6365840-1.htm
http://bbs.house.qq.com/t-6365858-1.htm
http://bbs.house.qq.com/t-6365886-1.htm
http://bbs.house.qq.com/t-6365922-1.htm
http://bbs.house.qq.com/t-6365945-1.htm
http://bbs.house.qq.com/t-6365958-1.htm
http://bbs.house.qq.com/t-6365981-1.htm
http://bbs.house.qq.com/t-6366010-1.htm
http://bbs.house.qq.com/t-6366039-1.htm
http://bbs.house.qq.com/t-6366103-1.htm
http://bbs.house.qq.com/t-6366146-1.htm
http://bbs.house.qq.com/t-6366159-1.htm
http://bbs.house.qq.com/t-6366183-1.htm
http://bbs.house.qq.com/t-6366200-1.htm
http://bbs.house.qq.com/t-6366216-1.htm
http://bbs.house.qq.com/t-6366242-1.htm
http://bbs.house.qq.com/t-6366262-1.htm
http://bbs.house.qq.com/t-6366284-1.htm
http://bbs.house.qq.com/t-6366314-1.htm
http://bbs.house.qq.com/t-6366341-1.htm
http://bbs.house.qq.com/t-6366368-1.htm
http://bbs.house.qq.com/t-6366402-1.htm
http://bbs.house.qq.com/t-6366427-1.htm
http://bbs.house.qq.com/t-6366465-1.htm
http://bbs.house.qq.com/t-6366492-1.htm
http://bbs.house.qq.com/t-6366508-1.htm
http://bbs.house.qq.com/t-6366525-1.htm
http://bbs.house.qq.com/t-6366548-1.htm
http://bbs.house.qq.com/t-6366573-1.htm
http://bbs.house.qq.com/t-6366592-1.htm
http://bbs.house.qq.com/t-6366616-1.htm
http://bbs.house.qq.com/t-6366629-1.htm
http://bbs.house.qq.com/t-6366653-1.htm
http://bbs.house.qq.com/t-6366677-1.htm
http://bbs.house.qq.com/t-6366690-1.htm
http://bbs.house.qq.com/t-6366718-1.htm
http://bbs.house.qq.com/t-6366738-1.htm
http://bbs.house.qq.com/t-6366762-1.htm
http://bbs.house.qq.com/t-6366779-1.htm
http://bbs.house.qq.com/t-6366795-1.htm
http://bbs.house.qq.com/t-6366808-1.htm
http://bbs.house.qq.com/t-6366830-1.htm
http://bbs.house.qq.com/t-6366866-1.htm
http://bbs.house.qq.com/t-6366896-1.htm
http://bbs.house.qq.com/t-6366920-1.htm
http://bbs.house.qq.com/t-6366934-1.htm
http://bbs.house.qq.com/t-6366952-1.htm
http://bbs.house.qq.com/t-6366967-1.htm
http://bbs.house.qq.com/t-6366984-1.htm
http://bbs.house.qq.com/t-6367010-1.htm
http://bbs.house.qq.com/t-6367027-1.htm
http://bbs.house.qq.com/t-6367044-1.htm
http://bbs.house.qq.com/t-6367058-1.htm
http://bbs.house.qq.com/t-6367074-1.htm
http://bbs.house.qq.com/t-6367091-1.htm
http://bbs.house.qq.com/t-6367107-1.htm
http://bbs.house.qq.com/t-6367121-1.htm
http://bbs.house.qq.com/t-6367133-1.htm
http://bbs.house.qq.com/t-6367148-1.htm
http://bbs.house.qq.com/t-6367160-1.htm
http://bbs.house.qq.com/t-6367175-1.htm
http://bbs.house.qq.com/t-6367190-1.htm
http://bbs.house.qq.com/t-6367202-1.htm
http://bbs.house.qq.com/t-6367214-1.htm
http://bbs.house.qq.com/t-6367231-1.htm
http://bbs.house.qq.com/t-6367256-1.htm
http://bbs.house.qq.com/t-6367282-1.htm
http://bbs.house.qq.com/t-6367294-1.htm
http://bbs.house.qq.com/t-6367308-1.htm
http://bbs.house.qq.com/t-6367360-1.htm
http://bbs.house.qq.com/t-6367383-1.htm
http://bbs.house.qq.com/t-6367397-1.htm
http://bbs.house.qq.com/t-6367422-1.htm
http://bbs.house.qq.com/t-6367437-1.htm
http://bbs.house.qq.com/t-6367454-1.htm
http://bbs.house.qq.com/t-6367475-1.htm
http://bbs.house.qq.com/t-6367487-1.htm
http://bbs.house.qq.com/t-6367505-1.htm
http://bbs.house.qq.com/t-6367519-1.htm
http://bbs.house.qq.com/t-6367535-1.htm
http://bbs.house.qq.com/t-6367550-1.htm
http://bbs.house.qq.com/t-6367566-1.htm
http://bbs.house.qq.com/t-6367579-1.htm
http://bbs.house.qq.com/t-6367594-1.htm
http://bbs.house.qq.com/t-6367622-1.htm
http://bbs.house.qq.com/t-6367639-1.htm
http://bbs.house.qq.com/t-6367661-1.htm
http://bbs.house.qq.com/t-6367698-1.htm
http://bbs.house.qq.com/t-6367737-1.htm
http://bbs.house.qq.com/t-6367784-1.htm
http://bbs.house.qq.com/t-6367812-1.htm
http://bbs.house.qq.com/t-6367856-1.htm
http://bbs.house.qq.com/t-6367881-1.htm
http://bbs.house.qq.com/t-6367894-1.htm
http://bbs.house.qq.com/t-6367912-1.htm
http://bbs.house.qq.com/t-6367938-1.htm
http://bbs.house.qq.com/t-6367968-1.htm
http://bbs.house.qq.com/t-6367987-1.htm
http://bbs.house.qq.com/t-6368021-1.htm
http://bbs.house.qq.com/t-6368064-1.htm
http://bbs.house.qq.com/t-6368082-1.htm
http://bbs.house.qq.com/t-6368447-1.htm
http://bbs.house.qq.com/t-6368480-1.htm
http://bbs.house.qq.com/t-6368503-1.htm
http://bbs.house.qq.com/t-6368517-1.htm
http://bbs.house.qq.com/t-6368541-1.htm
http://bbs.house.qq.com/t-6368573-1.htm
http://bbs.house.qq.com/t-6368599-1.htm
http://bbs.house.qq.com/t-6368620-1.htm
http://bbs.house.qq.com/t-6368634-1.htm
http://bbs.house.qq.com/t-6368648-1.htm
http://bbs.house.qq.com/t-6368709-1.htm
http://bbs.house.qq.com/t-6368724-1.htm
http://bbs.house.qq.com/t-6368737-1.htm
http://bbs.house.qq.com/t-6368754-1.htm
http://bbs.house.qq.com/t-6368798-1.htm
http://bbs.house.qq.com/t-6368811-1.htm
http://bbs.house.qq.com/t-6368824-1.htm
http://bbs.house.qq.com/t-6368873-1.htm
http://bbs.house.qq.com/t-6368890-1.htm
http://bbs.house.qq.com/t-6368905-1.htm
http://bbs.house.qq.com/t-6368921-1.htm
http://bbs.house.qq.com/t-6368953-1.htm
http://bbs.house.qq.com/t-6368990-1.htm
http://bbs.house.qq.com/t-6369006-1.htm
http://bbs.house.qq.com/t-6369028-1.htm
http://bbs.house.qq.com/t-6369051-1.htm
http://bbs.house.qq.com/t-6369073-1.htm
http://bbs.house.qq.com/t-6369092-1.htm
http://bbs.house.qq.com/t-6369109-1.htm
http://bbs.house.qq.com/t-6369180-1.htm
http://bbs.house.qq.com/t-6369224-1.htm
http://bbs.house.qq.com/t-6369251-1.htm
http://bbs.house.qq.com/t-6369271-1.htm
http://bbs.house.qq.com/t-6369283-1.htm
http://bbs.house.qq.com/t-6369318-1.htm
http://bbs.house.qq.com/t-6369339-1.htm
http://bbs.house.qq.com/t-6369353-1.htm
http://bbs.house.qq.com/t-6369374-1.htm
http://bbs.house.qq.com/t-6369430-1.htm
http://bbs.house.qq.com/t-6369451-1.htm
http://bbs.house.qq.com/t-6369475-1.htm
http://bbs.house.qq.com/t-6369497-1.htm
http://bbs.house.qq.com/t-6369523-1.htm
http://bbs.house.qq.com/t-6369539-1.htm
http://bbs.house.qq.com/t-6369552-1.htm
http://bbs.house.qq.com/t-6369566-1.htm
http://bbs.house.qq.com/t-6369580-1.htm
http://bbs.house.qq.com/t-6369593-1.htm
http://bbs.house.qq.com/t-6369608-1.htm
http://bbs.house.qq.com/t-6369625-1.htm
http://bbs.house.qq.com/t-6369640-1.htm
http://bbs.house.qq.com/t-6369655-1.htm
http://bbs.house.qq.com/t-6369699-1.htm
http://bbs.house.qq.com/t-6369722-1.htm
http://bbs.house.qq.com/t-6369738-1.htm
http://bbs.house.qq.com/t-6369771-1.htm
http://bbs.house.qq.com/t-6369809-1.htm
http://bbs.house.qq.com/t-6369824-1.htm
http://bbs.house.qq.com/t-6369873-1.htm
http://bbs.house.qq.com/t-6369919-1.htm
http://bbs.house.qq.com/t-6369933-1.htm
http://bbs.house.qq.com/t-6369950-1.htm
http://bbs.house.qq.com/t-6369967-1.htm
http://bbs.house.qq.com/t-6370020-1.htm
http://bbs.house.qq.com/t-6370040-1.htm
http://bbs.house.qq.com/t-6370056-1.htm
http://bbs.house.qq.com/t-6370069-1.htm
http://bbs.house.qq.com/t-6370088-1.htm
http://bbs.house.qq.com/t-6370129-1.htm
http://bbs.house.qq.com/t-6370146-1.htm
http://bbs.house.qq.com/t-6370157-1.htm
http://bbs.house.qq.com/t-6370190-1.htm
http://bbs.house.qq.com/t-6370232-1.htm
http://bbs.house.qq.com/t-6370245-1.htm
http://bbs.house.qq.com/t-6370259-1.htm
http://bbs.house.qq.com/t-6370272-1.htm
http://bbs.house.qq.com/t-6370297-1.htm
http://bbs.house.qq.com/t-6370312-1.htm
http://bbs.house.qq.com/t-6370368-1.htm
http://bbs.house.qq.com/t-6370398-1.htm
http://bbs.house.qq.com/t-6370414-1.htm
http://bbs.house.qq.com/t-6370438-1.htm
http://bbs.house.qq.com/t-6370456-1.htm


声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn