ÊʺϳõѧÕßѧϰµÄCSS3ʵÏÖÕÐÈËϲ»¶µÄ¶¯Îï
¸ø¶¯ÎïÔö¼Ó¶¯»ÌØЧ
CSS¹Ø¼üÖ¡²»¿Ë²»¼°ÎªÎÒÃǹ©¸øÒ»ÖÖÀû±ãµÄÅÅÐòºÍ×éºÏ¶¯»µÄ°ì·¨¡£½â¾öÕâ¸öÎÊÌâµÄ×îºÃ°ì·¨Êǽ«¶¯»·½°¸£¨¹ÊÊ°壩×÷Ϊʱ¼äÖᣬ²¢Ê¹ÓÃÔ¤´¦ÖÃÆ÷£¬ÈçSass£¬Éú³É¹Ø¼üÖ¡¡£
ÀýÈçºüÀ꣬ÔÚ¸ÅÊöÿ¸ö¶¯»Ó¦·¢ÉúµÄ¹ÊÊ°åÖ®ºó£¬×ª»»ºÍ¾ø¶Ôʱ¼äÆ«ÒÆ£¨Ã룩±»ÓÃÓÚ¶Ôÿ¸öÉíÌ岿·ÖÍ£Ö¹¶¯»´¦Öá£ÒÔÏÂÊÇSCSSÖжԺüÀê±Ç×ÓÍ£Ö¹¸ÅÊöµÄÒ»¸öÀý×Ó£º
$animations: ( // ... 'nose': ( // resting position (4s, 5s, 7s): rotateY(-4deg), // nose down 4.5s: rotateY(-4deg) rotateX(-3deg), // fox looks left (7.5s, 9s): rotateX(-3deg) rotateY(-28deg) rotateZ(-11deg), // fox looks right (9.5s, 12s): rotateY(7deg), // fox looks straight ahead 13s: rotateY(0), ), // ... );
ÔÚÕâÀ$animationsÊÇÒ»ÀàSass map£¬ÆäÖмüÊǶ¯»µÄÃû³Æ£¨ÀýÈç¡°nose¡±£©¡£Ã¿¸ö¶¯»Ãû³ÆµÄÖµÊÇÁíÒ»¸ömap£¬ÆäÖмüÊÇÒÔÃëΪµ¥Î»µÄÆ«ÒÆ»òÆ«ÒÆÁÐ±í£¨ÀýÈç(7.5s,9s)£©£¬²¢ÇÒÖµÊÇÿ¸öÆ«ÒƼüµÄtransformÊôÐÔ¡£
ÄÇô£¬ÎÒÃÇÈçºÎ°ÑÕâ¸ömap±ä³É@keyframe¶¯»ÄØ£¿µÚÒ»£¬É趨ȫ¾ÖµÄ$duration: 17s±äÁ¿¡ª¡ªÕ⽫ÊÇÿ¸ö¶¯»µÄ×ÜÁ¬Ðøʱ¼ä¡£È»ºó£¬Ê¹ÓÃǶÌ×µÄSass @each ... in ...
Âֻأ¬ÎÒÃÇ¿ÉÒÔͨ¹ý¶Ô$animations mapÂÖ»ØΪÿ¸ö¶¯»Éú³ÉÔ¤²âµÄCSS @keyframeÉùÃ÷£º
@each $animation-name, $animation in $animations { // keyframe declaration @keyframes #{$animation-name} { @each $offsets, $transform in $animation { @each $offset in $offsets { // offset declaration block #{percentage($offset / $duration)} { // transform property transform: #{$transform}; } } } } }
Õ⽫Éú³ÉÈçÏÂËùʾµÄ¹Ø¼üÖ¡£º
@keyframes nose { 14.70588% { transform: rotateY(-4deg); } 23.52941% { transform: rotateY(-4deg); } 29.41176% { transform: rotateY(-4deg); } 41.17647% { transform: rotateY(-4deg); } 26.47059% { transform: rotateY(-4deg) rotateX(-3deg); } 44.11765% { transform: rotateX(-3deg) rotateY(-28deg) rotateZ(-11deg); } 52.94118% { transform: rotateX(-3deg) rotateY(-28deg) rotateZ(-11deg); } 55.88235% { transform: rotateY(7deg); } 70.58824% { transform: rotateY(7deg); } 76.47059% { transform: rotateY(0); } }
ÔÚ²»Ê¹ÓÃSCSSµÄ×´¿öÏ£¬ÕâЩ°Ù·Ö±ÈµÄÔËËã´ó¸Å·Ç³£·±Ëö¡£ËüÃÇ´ú±í¶¯»µÄÿ¸ö²½ÖèÖÐÿ¸öËùÐèʱ¼äÖµÏà¹ØÓÚ×Ü$durationµÄ°Ù·Ö±ÈÆ«ÒÆÁ¿¡£
È»ºó¿ÉÒÔ½«¶¯»ÀûÓÃÓÚËüÃǸ÷×ÔµÄÉíÌ岿룬ÀýÈçanimation: nose $duration none infinite;¡£Ã¿¸ö¶¯»µÄÁ¬Ðøʱ¼ä¶¼µÃÊÇÒ»ÑùµÄ£¬ÕâÑùËüÃÇ¿ÉÒÔÎÞ·ìÂֻء£
±ÆÕæµÄEasing Curves
ÖÆ×÷¶¯»µÄÁíÒ»¸öÖØÒª×é³É²¿·ÖÊÇ¿´ÉÏÈ¥Òª±ÆÕ棬ËùÒÔҪΪ¶¯»µÄÿ¸ö²¿·ÖϸÐÄÑ¡ÖУ¨»ò´´Á¢£©Easing Curves¡£×îΪÉú¶¯µÄEasing CurvesÊÇ¡°ÕýÏÒÇúÏß¡±¡ª¡ª»»¾ä»°Ëµ£¬ÊÇƽ»¬Æð·üµÄEasing Curves¡£ÕâÑùÒ»À´£¬ÌìÈ»¶¯×÷¾Í²»»áÉúÓ²µØÆ𶯻òÐÝÖ¹£¬animation-timing-functionÓ¦µ±ÄÜ·´Ó³³öÀ´¡£
¹ØÓÚºüÀêºÍ¹þÊ¿Æ棬ÎÒʹÓÃcubic-bezier(0.645, 0.045, 0.355, 1)£¨ÔÚÕâÀïÔ¤ÀÀ£©¡£´ËÇúÏߣ¨¼ûÏÂÎÄ£©¿ª¶ËÂԿ죬ȻºóƽÎȵØͣס¡£µ±È»£¬×îºÃÊÔÑéÇúÏßÒÔÑ°µ½×îÊʺ϶¯»µÄÄÇÖÖ¡£
×îºó£ºÔÚChromeÖУ¬Äã¿ÉÒÔÖ±²»Ñŵؼì²éËùÓÐÅÅÐòµÄ¶¯»£¬ÒÔÈ·±£ËüÃÇÔÚ׼ȷµÄʱ¼ä·¢Éú¡£ÄãÖ»Ðè·¿ª²Ù×Ý̨£¬µ¥»÷StyleÑ¡Ï£¬È»ºóµ¥»÷²¥·Å°´Å¥¼´¿É£º
µ«Ô¸±¾½Ì³Ì¿ÉÒÔ°ïæÆôʾÄã´´Á¢¸ü¶àµÄÐòÁÐCSS¶¯Îﶯ»£¡
¸ü¶àÏà¹Ø֪ʶ£¬Çë°Ý·Ã PHPÖÐÎÄÍø£¡£¡
ÒÔÉϾÍÊÇÊʺϳõѧÕßѧϰµÄCSS3ʵÏÖÕÐÈËϲ»¶µÄ¶¯ÎïµÄ¾ßÌåÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢°Ù·Ö°ÙÔ´ÂëÍøÆäËüÏà¹ØÎÄÕ£¡
¸ÐлÄúµÄÖ§³Ö£¬ÎÒ»á¼ÌÐøŬÁ¦µÄ!
´ò¿ªÖ§¸¶±¦É¨Ò»É¨£¬¼´¿É½øÐÐɨÂë´òÉÍŶ
°Ù·Ö°ÙÔ´ÂëÍø ½¨Òé´òÉÍ1¡«10Ôª£¬ÍÁºÀËæÒ⣬¸ÐлÄúµÄÔĶÁ£¡