{"id":7618,"date":"2018-06-11T23:49:55","date_gmt":"2018-06-11T15:49:55","guid":{"rendered":"http:\/\/www.zhangxinxu.com\/wordpress\/?p=7618"},"modified":"2018-11-15T17:06:27","modified_gmt":"2018-11-15T09:06:27","slug":"css3-animation-steps-step-start-end","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2018\/06\/css3-animation-steps-step-start-end\/","title":{"rendered":"CSS3 animation\u5c5e\u6027\u4e2d\u7684steps\u529f\u80fd\u7b26\u6df1\u5165\u4ecb\u7ecd"},"content":{"rendered":"<p>by <a href=\"http:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=7618\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=7618<\/a><br \/>\n\u672c\u6587\u53ef\u5168\u6587\u8f6c\u8f7d\uff0c\u4f46\u9700\u8981\u4fdd\u7559\u539f\u4f5c\u8005\u548c\u51fa\u5904\uff0c\u6458\u8981\u5f15\u6d41\u5219\u968f\u610f\u3002<\/p>\n<h3>\u4e00\u3001\u4e0d\u53ea\u662f\u8fde\u7eed\u7684\u53d8\u5316\u624d\u53eb\u52a8\u753b<\/h3>\n<style>@keyframes wpSpin {0% {transform: rotate(0);}100% {transform: rotate(360deg);}}.ani-rot1{animation: wpSpin 1s linear infinite; }.ani-rot2{animation: wpSpin 1s steps(4) infinite; }.ani-rot3{animation: wpSpin 1s steps(8, end) infinite; }<\/style>\n<p>\u6211\u5f88\u65e9\u7684\u65f6\u5019\u6709\u4e2a\u9519\u8bef\u8ba4\u77e5\uff0c\u8ba4\u4e3a\u53ea\u6709\u8fde\u7eed\u7684\u53d8\u5316\u624d\u53eb\u52a8\u753b\uff1b\u542b\u7b11\u534a\u6b65\u766b\u90a3\u6837\u7684\u6548\u679c\u4e0d\u662f\u52a8\u753b\u3002<\/p>\n<p>\u540e\u6765\u624d\u660e\u767d\uff0c\u53ea\u8981\u6709\u8f68\u8ff9\u53ef\u5faa\uff0c\u5373\u4f7f\u8089\u773c\u770b\u4e0a\u53bb\u662f\u65ad\u65ad\u7eed\u7eed\u7684\uff0c\u5b9e\u9645\u4e0a\u4e5f\u662f\u52a8\u753b\u3002<\/p>\n<p>\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u73b0\u6709\u7d20\u6750\u56fe\u5982\u4e0b\uff1a<\/p>\n<p><img src=http:\/\/image.zhangxinxu.com\/image\/blog\/201806\/loading-blue.png width=\"30\" height=\"30\"><\/p>\n<p>\u8bf7\u95ee\u4e0b\u9762\u4e24\u4e2a\u56fe\u5f62\u53d8\u5316\uff0c\u54ea\u4e2a\u5c5e\u4e8e\u52a8\u753b\u6548\u679c\uff1f<\/p>\n<p><img src=\/\/image.zhangxinxu.com\/image\/blog\/201806\/loading-blue.png width=\"30\" height=\"30\" class=\"ani-rot1\"><\/p>\n<p><img src=\/\/image.zhangxinxu.com\/image\/blog\/201806\/loading-blue.png width=\"30\" height=\"30\" class=\"ani-rot2\"><\/p>\n<p>\u7b54\u6848\u662f\uff1a\u4e24\u4e2a\u90fd\u662f\u3002<\/p>\n<p>\u6211\u4eec\u5982\u679c\u6362\u4e00\u79cd\u7d20\u6750\uff0c\u5927\u5bb6\u5c31\u80fd\u77e5\u9053\u975e\u8fde\u7eed\u56fe\u5f62\u53d8\u5316\u4e5f\u662f\u52a8\u753b\u4e86\u3002<\/p>\n<p><img src=\/\/image.zhangxinxu.com\/image\/blog\/201806\/loading-dot.png width=\"30\" height=\"30\"><\/p>\n<p>\u6548\u679c\u5206\u522b\u4e3a\u8fde\u7eed\u65cb\u8f6c\u548c\u65ad\u7eed\u65cb\u8f6c\u3002<\/p>\n<p><img src=\/\/image.zhangxinxu.com\/image\/blog\/201806\/loading-dot.png width=\"30\" height=\"30\" class=\"ani-rot1\"><\/p>\n<p><img src=\/\/image.zhangxinxu.com\/image\/blog\/201806\/loading-dot.png width=\"30\" height=\"30\" class=\"ani-rot3\"><\/p>\n<p>\u540e\u9762\u4e00\u5f20\u56fe\u5c31\u662f\u975e\u8fde\u7eed\u53d8\u5316\u4e0b\u7684\u6548\u679c\uff0c\u53cd\u800c\u662f\u6211\u4eec\u5b9e\u9645\u9879\u76ee\u4e2d\u6b63\u786e\u7684\u83ca\u82b1loading\u6548\u679c\u3002<\/p>\n<p>\u800c\u5b9e\u73b0\u7684\u5173\u952e\u5c31\u662f\u672c\u6587\u8981\u6df1\u5165\u4ecb\u7ecd\u7684<code>steps()<\/code>\u529f\u80fd\u7b26\u3002<\/p>\n<h3>\u4e8c\u3001\u4e00\u53e5\u8bdd\u4ecb\u7ecdsteps()\u529f\u80fd\u7b26<\/h3>\n<p><code>steps()<\/code>\u529f\u80fd\u7b26\u53ef\u4ee5\u8ba9\u52a8\u753b\u4e0d\u8fde\u7eed\u3002<\/p>\n<h3>\u4e09\u3001steps()\u5728CSS3 animation\u4e2d\u5730\u4f4d<\/h3>\n<p><code>steps()<\/code>\u529f\u80fd\u7b26\u548cCSS3 animation\u4e2d\u7684<code>cubic-bezier()<\/code>\u529f\u80fd\u7b26\u7684\u5730\u4f4d\u548c\u4f5c\u7528\u662f\u4e00\u6837\u7684\uff0c\u90fd\u53ef\u4ee5\u4f5c\u4e3a<code>animation-timing-function<\/code>\u7684\u5c5e\u6027\u503c\u3002<\/p>\n<p>\u53ea\u4e0d\u8fc7<code>steps()<\/code>\u66f4\u50cf\u662f\u697c\u68af\u5761\u9053\uff0c<code>cubic-bezier()<\/code>\u66f4\u50cf\u662f\u65e0\u969c\u788d\u5761\u9053\u3002\u5982\u4e0b\u56fe\u793a\u610f\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201806\/podao-steps.png\" alt=\"\u65e0\u969c\u788d\u5761\u9053\u4e0e\u52a8\u753b\u5173\u7cfb\u793a\u610f\" width=\"210\" height=\"96\"><\/p>\n<p>\u7136\u540e<code>steps()<\/code>\u7b80\u5316\u51fa\u4e86<code>step-start<\/code>\u548c<code>step-end<\/code>\u8fd9\u4e24\u4e2a\u5173\u952e\u5b57\uff1b<code>cubic-bezier()<\/code>\u5219\u6709<code>linear<\/code>\uff0c<code>ease<\/code>\uff0c<code>ease-in<\/code>\uff0c<code>ease-out<\/code>\u4ee5\u53ca<code>ease-in-out<\/code>\u3002<\/p>\n<p><code>cubic-bezier<\/code>\u6307\u4e09\u6b21\u8d1d\u585e\u5c14\u66f2\u7ebf\uff0c\u5177\u4f53\u53ef\u53c2\u89c1\u6211\u4e4b\u524d\u6587\u7ae0\u201c<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/2014\/06\/deep-understand-svg-path-bezier-curves-command\/\">\u6df1\u5ea6\u638c\u63e1SVG\u8def\u5f84path\u7684\u8d1d\u585e\u5c14\u66f2\u7ebf\u6307\u4ee4<\/a>\u201d\u3002<\/p>\n<p><code>steps()<\/code>\u6307\u9010\u6b65\u8fd0\u52a8\uff0c\u4e0b\u9762\u8fdb\u4e00\u6b65\u6df1\u5165\u4ecb\u7ecd\u3002<\/p>\n<h3>\u56db\u3001\u641e\u6e05\u695asteps()\u4e2d\u7684<code>start<\/code>\u548c<code>end<\/code><\/h3>\n<p><code>steps()<\/code>\u6709\u4e00\u5b9a\u7684\u5b66\u4e60\u96be\u5ea6\uff0c\u603b\u662f\u641e\u4e0d\u6e05\u695a\uff0c\u6700\u4e3b\u8981\u5c31\u662f<code>start<\/code>\u548c<code>end<\/code>\u50bb\u50bb\u5206\u4e0d\u6e05\u695a\u3002\u6211\u8fd9\u91cc\u81ea\u6211\u6311\u6218\u4e0b\uff0c\u770b\u770b\u80fd\u4e0d\u80fd\u8bf4\u6e05\u695a\u3002<\/p>\n<p>\u5e38\u89c1<code>steps()<\/code>\u7528\u6cd5\u4e3e\u4f8b\uff1a<\/p>\n<pre>steps(5, end);\nsteps(2, start);<\/pre>\n<p>\u7528<code>steps()<\/code>\u8bed\u6cd5\u8868\u793a\u5c31\u662f\uff1a<\/p>\n<pre>steps(number, position)<\/pre>\n<p>\u5176\u4e2d\uff1a<\/p>\n<dl>\n<dt><strong>number<\/strong><\/dt>\n<dd>\u6570\u503c\u3002\u8fd9\u4e2a\u5f88\u597d\u7406\u89e3\uff0c\u8868\u793a\u628a\u6211\u4eec\u7684\u52a8\u753b\u5206\u6210\u4e86\u591a\u5c11\u6bb5\u3002<\/p>\n<p>\u5047\u8bbe\u6709\u5982\u4e0bCSS3\u52a8\u753b<code>keyframes<\/code>\uff0c\u5b9a\u4e49\u4e86\u4e00\u6bb5\u4ece<code>0~100px<\/code>\u7684\u4f4d\u79fb\uff1a<\/p>\n<pre>@keyframes move {\n    0% { left: 0; }\n    100% { left: 100px; }\n}<\/pre>\n<p>\u5047\u8bbe\u6211\u4eec\u7684<code>number<\/code>\u503c\u662f5\uff0c\u5219\u76f8\u5f53\u4e8e\u628a\u8fd9\u6bb5\u79fb\u52a8\u8ddd\u79bb\u5206\u6210\u4e865\u6bb5\uff0c\u5982\u4e0b\u793a\u610f\u56fe\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201806\/2018-06-11_214140.png\" width=\"349\" height=\"75\" alt=\"steps\u5206\u6bb5\u793a\u610f\u56fe\" class=\"alignnone\" \/>\n<\/dd>\n<dt><strong>position<\/strong><\/dt>\n<dd>\u5173\u952e\u5b57\u3002\u8868\u793a\u52a8\u753b\u662f\u4ece\u65f6\u95f4\u6bb5\u7684\u5f00\u5934\u8fde\u7eed\u8fd8\u662f\u672b\u5c3e\u8fde\u7eed\u3002\u652f\u6301<code>start<\/code>\u548c<code>end<\/code>\u4e24\u4e2a\u5173\u952e\u5b57\uff0c\u542b\u4e49\u5206\u522b\u5982\u4e0b\uff1a<\/dd>\n<ul>\n<li><code>start<\/code>\uff1a\u8868\u793a\u76f4\u63a5\u5f00\u59cb\u3002<\/li>\n<li><code>end<\/code>\uff1a\u8868\u793a\u621b\u7136\u800c\u6b62\u3002\u662f\u9ed8\u8ba4\u503c\u3002<\/li>\n<\/ul>\n<\/dl>\n<h4>\u4e3a\u4ec0\u4e48position\u975e\u5e38\u96be\u7406\u89e3\uff1f<\/h4>\n<p>\u6211\u8ba4\u4e3a\u4e24\u4e2a\u539f\u56e0\uff1a<\/p>\n<ol>\n<li><code>steps()<\/code>\u5c5e\u4e8etiming function\uff0c\u4e5f\u5c31\u662f\u65f6\u95f4\u51fd\u6570\uff0c\u65f6\u95f4\u8fd9\u4e2a\u4e1c\u897f\u662f\u865a\u7684\uff0c\u770b\u4e0d\u89c1\uff0c\u6478\u4e0d\u7740\uff0c\u8054\u60f3\u4e4f\u529b\uff0c\u6240\u4ee5\u8ba4\u77e5\u6210\u672c\u9ad8\u3002\u8fd9\u4e5f\u662f\u4e3a\u4ec0\u4e48\u90a3\u4e48\u591a\u4eba\u90fd\u4e0d\u73cd\u60dc\u65f6\u95f4\u7684\u539f\u56e0\u2014\u2014\u65e0\u6cd5\u611f\u77e5\u3002<\/li>\n<li>CSS\u89c4\u8303\u4e2d\u5bf9\u4e8e<code>start<\/code>\u548c<code>end<\/code>\u7684\u5b9a\u4e49\u662f\u57fa\u4e8e\u6570\u5b66\u51fd\u6570\u6765\u7684\uff0c\u51fd\u6570\u8fd9\u4e1c\u897f\uff0c\u591a\u5c11\u4eba\u7684\u5669\u68a6\uff0c\u56e0\u4e3a\u8fc7\u4e8e\u62bd\u8c61\uff0c\u4e0e\u73b0\u5b9e\u96be\u4ee5\u5173\u8054\uff0c\u6240\u4ee5\uff0c\u5982\u679c\u6211\u4eec\u76ef\u7740\u5b9a\u4e49\u53bb\u7406\u89e3<code>start<\/code>\u548c<code>end<\/code>\uff0c\u90a3\u5c31\u662f\u6b7b\u80e1\u540c\uff0c\u4e0d\u5f52\u8def\uff0c\u5c31\u7b97\u73b0\u5728\u5f04\u61c2\u4e86\uff0c\u8fc7\u6bb5\u65f6\u95f4\u518d\u9047\u5230\uff0c\u5f97\u4e86\uff0c\u5168\u5fd8\u5149\u5149\u4e86\uff0c\u51fd\u6570\u56fe\u54ea\u4e2a\u662f\u54ea\u4e2a\uff0c\u9b3c\u624d\u8bb0\u5f97\u3002\u4e0b\u9762\u8fd9\u5f20\u56fe\u5c31\u51fa\u81ea<a href=\"https:\/\/www.w3.org\/TR\/css-timing-1\/#step-timing-functions\" rel=\"noopener\" target=\"_blank\">\u89c4\u8303\u6587\u6863<\/a>\uff1a\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201806\/step-timing-func-examples.svg\" width=\"400\" height=\"490\" alt=\"steps()\u89c4\u8303\u51fd\u6570\u793a\u610f\" class=\"alignnone\" \/><\/p>\n<p>\u6309\u7167\u89c4\u8303\u56fe\u518d\u7ec6\u5316\u89e3\u91ca\u5c31\u662f\uff1a<\/p>\n<ul>\n<li><code>start<\/code>\uff1a\u8868\u793a\u76f4\u63a5\u5f00\u59cb\u3002\u4e5f\u5c31\u662f\u65f6\u95f4\u624d\u5f00\u59cb\uff0c\u5c31\u5df2\u7ecf\u6267\u884c\u4e86\u4e00\u4e2a\u8ddd\u79bb\u6bb5\u3002\u4e8e\u662f\uff0c\u52a8\u753b\u6267\u884c\u76845\u4e2a\u5206\u6bb5\u70b9\u662f\u4e0b\u9762\u8fd95\u4e2a\uff0c\u8d77\u59cb\u70b9\u88ab\u5ffd\u7565\uff0c\u56e0\u4e3a\u65f6\u95f4\u4e00\u5f00\u59cb\u76f4\u63a5\u5c31\u5230\u4e86\u7b2c\u4e8c\u4e2a\u70b9\uff1a\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201806\/2018-06-11_223135.png\" width=\"365\" height=\"136\" alt=\"start\u6267\u884c\u7684\u5173\u952e\u70b9\" class=\"alignnone\" \/><\/li>\n<li><code>end<\/code>\uff1a\u8868\u793a\u621b\u7136\u800c\u6b62\u3002\u4e5f\u5c31\u662f\u65f6\u95f4\u4e00\u7ed3\u675f\uff0c\u5f53\u524d\u8ddd\u79bb\u4f4d\u79fb\u5c31\u505c\u6b62\u3002\u4e8e\u662f\uff0c\u52a8\u753b\u6267\u884c\u76845\u4e2a\u5206\u6bb5\u70b9\u662f\u4e0b\u9762\u8fd95\u4e2a\uff0c\u7ed3\u675f\u70b9\u88ab\u5ffd\u7565\uff0c\u56e0\u4e3a\u7b49\u8981\u6267\u884c\u7ed3\u675f\u70b9\u7684\u65f6\u5019\u5df2\u7ecf\u6ca1\u65f6\u95f4\u4e86\uff1a\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201806\/2018-06-11_223630.png\" width=\"359\" height=\"117\" alt=\"end\u6267\u884c\u7684\u5173\u952e\u70b9\" class=\"alignnone\" \/><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h4>\u57fa\u4e8e\u73b0\u5b9e\u611f\u77e5\u91cd\u65b0\u7406\u89e3position\uff01<\/h4>\n<p>\u4e07\u7269\u5177\u6709\u76f8\u5bf9\u6027\u3002\u4f8b\u5982\uff0c\u82cd\u8747\u773c\u4e2d\u7684\u4eba\u7c7b\u52a8\u4f5c\u90fd\u662f\u6162\u52a8\u4f5c\uff0c\u4f46\u662f\u4eba\u7c7b\u773c\u4e2d\u7684\u82cd\u8747\u5374\u975e\u5e38\u654f\u6377\u3002<\/p>\n<p>\u540c\u6837\u7684\uff0c<code>start<\/code>\u548c<code>end<\/code>\u8fd9\u91cc\u7684\u5f00\u59cb\u548c\u7ed3\u675f\u662f\u76f8\u5bf9\u4e8e\u65f6\u95f4\u800c\u8a00\u7684\uff0c\u4f46\u662f\uff0c\u5982\u679c\u7ad9\u5728\u4eba\u7c7b\u53ef\u611f\u77e5\u7684\u5177\u4f53\u4e8b\u7269\u800c\u8a00\uff0c<code>start<\/code>\u548c<code>end<\/code>\u5374\u662f\u76f8\u53cd\u7684\u542b\u4e49\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u6211\u4eec\u53ef\u4ee5\u8fd9\u4e48\u7406\u89e3\uff1a<\/p>\n<ul>\n<li><code>start<\/code>\uff1a\u8868\u793a\u7ed3\u675f\u3002\u5206\u6bb5\u7ed3\u675f\u7684\u65f6\u5019\uff0c\u65f6\u95f4\u624d\u5f00\u59cb\u8d70\u3002\u4e8e\u662f\uff0c\u52a8\u753b\u6267\u884c\u76845\u4e2a\u5206\u6bb5\u70b9\u662f\u540e5\u4e2a\u70b9\uff1a\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201806\/2018-06-11_223135.png\" width=\"365\" height=\"136\" alt=\"start\u6267\u884c\u7684\u5173\u952e\u70b9\" class=\"alignnone\" \/><\/li>\n<li><code>end<\/code>\uff1a\u8868\u793a\u5f00\u59cb\u3002\u5206\u6bb5\u5f00\u59cb\u7684\u65f6\u5019\uff0c\u65f6\u95f4\u8ddf\u7740\u4e00\u8d77\u8d70\u3002\u4e8e\u662f\uff0c\u52a8\u753b\u6267\u884c\u76845\u4e2a\u5206\u6bb5\u70b9\u662f\u524d5\u4e2a\u70b9\uff1a\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201806\/2018-06-11_223630.png\" width=\"359\" height=\"117\" alt=\"end\u6267\u884c\u7684\u5173\u952e\u70b9\" class=\"alignnone\" \/><\/li>\n<\/ul>\n<h4>\u8bb0\u4f4fposition\u53c2\u6570\u7684\u542b\u4e49<\/h4>\n<p>\u7262\u8bb0\u8fd9\u4e48\u4e00\u53e5\u8bdd\uff1a<strong>\u4e00\u5207\u90fd\u662f\u53cd\u7684\uff01start\u4e0d\u662f\u5f00\u59cb\uff0c\u800c\u662f\u7ed3\u675f\uff1bend\u4e0d\u662f\u7ed3\u675f\uff0c\u800c\u662f\u5f00\u59cb\u3002<\/strong><\/p>\n<h3>\u4e94\u3001step-start\u548cstep-end<\/h3>\n<p><code>step-start<\/code>\u548c<code>step-end<\/code>\u662f<code>steps()<\/code>\u529f\u80fd\u7b26\u7b80\u5316\u5173\u952e\u5b57\uff0c\u6ce8\u610f\uff0c\u662f<code>step-*<\/code>\uff0c<code>step<\/code>\uff0c\u540e\u9762\u6ca1\u6709<code>s<\/code>\u3002<\/p>\n<p>\u5176\u4e2d\uff0c<code>step-start<\/code>\u7b49\u540c\u4e8e<code>steps(1, start)<\/code>\uff0c<code>step-end<\/code>\u7b49\u540c\u4e8e<code>steps(1, end)<\/code>\u6216\u8005<code>steps(1)<\/code>\u3002<\/p>\n<p><code>step-start<\/code>\u548c<code>step-end<\/code>\u7528\u4e2d\u6587\u77ed\u53e5\u89e3\u8bfb\u5c31\u662f\uff1a\u4e00\u6b65\u5230\u4f4d\u548c\u5ef6\u8fdf\u5230\u4f4d\uff0c\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u6709\u4ec0\u4e48\u4f5c\u7528\u5462\uff1f<\/p>\n<p>\u5bf9\u4e8e\u53ea\u6709<code>0%,100%<\/code>\u6216<code>from, to<\/code>\u4e24\u4e2a\u5173\u952e\u65f6\u95f4\u5e27\u7684\u52a8\u753b\uff0c<code>step-start<\/code>\u548c<code>step-end<\/code>\u662f\u6ca1\u6709\u4efb\u4f55\u9700\u8981\u4f7f\u7528\u7684\u7406\u7531\u7684\u3002<\/p>\n<p>\u5982\u679c\u662f\u975e\u7b49\u5206\uff0c\u65e0\u6cd5\u8fc7\u6e21\u7684\u9636\u68af\u52a8\u753b\uff0c\u5219\u6709\u4f7f\u7528\u4ef7\u503c\uff0c\u4f8b\u5982\u4e0b\u9762\u8fd9\u4e2a\u57fa\u4e8e<code>box-shadow<\/code>\u5b9e\u73b0\u7684\u6253\u70b9\u52a8\u753b\u6548\u679c\uff1a<\/p>\n<style>.dotting { display: inline-block; min-width: 2px; min-height: 2px; margin-right: 8px; box-shadow: 2px 0 currentColor, 6px 0 currentColor, 10px 0 currentColor; animation: dot 4s infinite step-start both;}@keyframes dot { 25% { box-shadow: none; } 50% { box-shadow: 2px 0 currentColor; } 75% { box-shadow: 2px 0 currentColor, 6px 0 currentColor;}\n}<\/style>\n<p><button>\u8ba2\u5355\u63d0\u4ea4\u4e2d<span class=\"dotting\"><\/span><\/button><\/p>\n<p>\u5b9e\u73b0\u6838\u5fc3\u4ee3\u7801\u5982\u4e0b\uff08\u6b64\u6253\u70b9\u65b9\u6cd5\u6700\u591a\u6392\u7eafCSS\u6253\u70b9\u52a8\u753b\u7b2c3\u4f4d\uff0c\u66f4\u591a\u89c1<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/2014\/12\/css3-animation-dotting-loading\/\">\u6b64\u6587<\/a>\u4ecb\u7ecd\u548c\u6307\u5f15\uff09\uff1a<\/p>\n<pre>&lt;button&gt;\u8ba2\u5355\u63d0\u4ea4\u4e2d&lt;span class=\"dotting\"&gt;&lt;\/span&gt;&lt;\/button&gt;<\/pre>\n<pre>.dotting {\n    display: inline-block; min-width: 2px; min-height: 2px;\n    margin-right: 8px;\n    box-shadow: 2px 0, 6px 0, 10px 0;\n    animation: dot 4s infinite <span style=\"color:#cd0000;\">step-start<\/span> both;\n}\n@keyframes dot {\n    25% { box-shadow: none; }          <span style=\"color:green;\">\/* 0\u4e2a\u70b9 *\/<\/span>\n    50% { box-shadow: 2px 0; }         <span style=\"color:green;\">\/* 1\u4e2a\u70b9 *\/<\/span>\n    75% { box-shadow: 2px 0, 6px 0; }  <span style=\"color:green;\">\/* 2\u4e2a\u70b9 *\/<\/span> \n}<\/pre>\n<h3>\u516d\u3001steps()\u4e0e\u586b\u5145\u6a21\u5f0fanimation-fill-mode<\/h3>\n<p><code>animation-fill-mode<\/code>\u6709\u65f6\u5019\u4e5f\u4f1a\u5f71\u54cd<code>steps()<\/code>\u7684\u65ad\u70b9\u8868\u73b0\uff0c\u4f8b\u5982\u4e0b\u9762\u8fd9\u4e2a\u8bed\u53e5\uff1a<\/p>\n<pre>animation: move 5s forwards steps(5, end);<\/pre>\n<p>\u52a8\u753b\u53ea\u6267\u884c\u4e00\u6b21\uff0c\u56e0\u4e3a\u6ca1\u6709\u8bbe\u7f6e<code>infinite<\/code>\u65e0\u9650\u5faa\u73af\uff0c\u800c<code>forwards<\/code>\u867d\u7136\u8868\u793a\u201c\u524d\u201d\uff0c\u4f46\u540c\u6837\u548c\u73b0\u5b9e\u8868\u73b0\u662f\u53cd\u7684\uff0c\u4e5f\u5c31\u662f\u52a8\u753b\u7ed3\u675f\u65f6\u5019\u5143\u7d20\u4fdd\u6301\u52a8\u753b\u5173\u952e\u5e27\u6700\u540e\u7684\u72b6\u6001\u3002\u4e8e\u662f\uff0c\u4e0b\u97626\u4e2a\u5206\u6bb5\u70b9\u90fd\u4f1a\u6267\u884c\uff0c\u6574\u4e2a\u52a8\u753b\u505c\u6b62\u5728\u7b2c6\u4e2a\u5206\u6bb5\u70b9\u4e0a\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201806\/2018-06-11_233301.png\" width=\"348\" height=\"111\" alt=\"forwards\u6267\u884c\u6700\u540e\u4e00\u4e2a\u5206\u6bb5\u70b9\" class=\"alignnone\" \/><\/p>\n<p>\u8fd9\u663e\u7136\u4e0d\u662f\u6211\u4eec\u60f3\u8981\u7684\uff0c\u600e\u4e48\u5904\u7406\u5462\uff1f<\/p>\n<p>\u53ef\u4ee5\u6d88\u51cf\u5206\u6bb5\u4e2a\u6570\u548c\u52a8\u753b\u8fd0\u52a8\u7684\u8de8\u5ea6\uff0c\u8c03\u6574\u5982\u4e0b\uff1a<\/p>\n<pre>@keyframes move {\n    0% { left: 0; }\n    100% { left: 80px; }\n}<\/pre>\n<p>\u4e5f\u5c31\u662f\u539f\u6765\u7ec8\u70b9<code>100px<\/code>\u6539\u6210<code>80px<\/code>\uff0c\u540c\u65f6CSS\u8c03\u7528\u6539\u6210\uff1a<\/p>\n<pre>animation: move 5s forwards steps(4, end);<\/pre>\n<p>\u4e5f\u5c31\u662f\u539f\u6765<code>steps(5, end)<\/code>\u6539\u6210<code>steps(4, end)<\/code>\uff0c\u6700\u540e<code>100%<\/code>\u8fd9\u4e00\u5e27\u4ea4\u7ed9<code>forwards<\/code>\u5373\u53ef\uff01<\/p>\n<h3>\u4e03\u3001\u7ed3\u675f\u8bed<\/h3>\n<p><code>steps()<\/code>\u662f\u4e00\u4e2a\u7528\u5f97\u6bd4\u8f83\u591a\u7684\u529f\u80fd\u7b26\uff0c\u9664\u4e86\u672c\u6587\u5c55\u793a\u7684loading\u6548\u679c\uff0c\u5728\u9010\u5e27\u52a8\u753b\u4e2d\u7528\u5f97\u975e\u5e38\u591a\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u4e00\u4e9b\u4e0d\u592a\u590d\u6742\u7684\u95ea\u5c4f\u6548\u679c\uff0c\u5199\u5c0f\u800c\u7f8e\u7684\u52a8\u753b\u6548\u679c\u7b49\uff08\u6709\u540d\u7684\u5982\uff1a\u70b9\u8d5e\u793c\u82b1\u6548\u679c\uff09\u3002<\/p>\n<p>\u6df1\u5165\u7406\u89e3<code>steps()<\/code>\u7684\u597d\u5904\u5728\u4e8e\uff0c\u5f53\u6211\u4eec\u5728\u5b9e\u73b0\u8fd9\u4e9b\u52a8\u753b\u6548\u679c\u65f6\u5019\uff0c\u7701\u53bb\u4e86\u5f88\u591a\u67e5\u9605\u6587\u6863\u5957\u7528\u8bed\u6cd5\u7684\u65f6\u95f4\uff0c\u8fd8\u7701\u6389\u4e86\u5f88\u591a\u4e00\u4e2a\u4e00\u4e2a<code>number<\/code>\u503c\u8c03\u8bd5\u7684\u65f6\u95f4\u3002\u53ef\u4ee5\u8ba9\u4f60\u5e72\u6d3b\u6548\u7387\u52a0\u500d\uff0c\u6709\u66f4\u591a\u65f6\u95f4\u5b66\u4e60\u5176\u4ed6\u4e1c\u897f\uff0c\u5f62\u6210\u6b63\u5411\u5faa\u73af\uff0c\u4e45\u800c\u4e45\u4e4b\uff0c\u5fc5\u5f53\u5b66\u6709\u6240\u6210\u3002<\/p>\n<p>\u5c31\u8fd9\u4e9b\uff0c\u611f\u8c22\u60a8\u82b1\u5b9d\u8d35\u65f6\u95f4\u4e00\u76f4\u9605\u8bfb\u5230\u8fd9\u91cc\uff01<\/p>\n<p>\u6b22\u8fce\u4ea4\u6d41\uff01<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201611\/14.png\" align=\"absmiddle\"><\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u4f1a\u7ecf\u5e38\u66f4\u65b0\u77e5\u8bc6\u70b9\u4ee5\u53ca\u4fee\u6b63\u4e00\u4e9b\u9519\u8bef\uff0c\u56e0\u6b64\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u539f\u51fa\u5904\uff0c\u65b9\u4fbf\u6eaf\u6e90\uff0c\u907f\u514d\u9648\u65e7\u9519\u8bef\u77e5\u8bc6\u7684\u8bef\u5bfc\uff0c\u540c\u65f6\u6709\u66f4\u597d\u7684\u9605\u8bfb\u4f53\u9a8c\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=7618\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=7618<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>steps()\u6709\u4e00\u5b9a\u7684\u5b66\u4e60\u96be\u5ea6\uff0c\u5f88\u591a\u6982\u5ff5\u603b\u662f\u641e\u4e0d\u6e05\u695a\uff0c\u6240\u4ee5\u672c\u6587\u7b97\u662f\u4e2a\u81ea\u6211\u6311\u6218\uff0c\u770b\u770b\u80fd\u4e0d\u80fd\u8bf4\u6e05\u695asteps()\u4e2d\u7684\u76f8\u5173\u6982\u5ff5\uff0c\u65b9\u4fbf\u5927\u5bb6\u7406\u89e3\u4e0e\u5b66\u4e60\u3002\u672c\u6587\u6709\u4e9b\u7bc7\u5e45\uff0c\u6709\u4e9b\u6df1\u5165\uff0c\u5982\u679c\u60a8\u65f6\u95f4\u8f83\u7d27\uff0c\u53ef\u4ee5\u5148\u9a6c\u540e\u770b\u3002\u603b\u4e4b\uff0c\u5e0c\u671b\u672c\u6587\u7684\u5185\u5bb9\u80fd\u591f\u5bf9\u60a8\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[531,831,1269,177,860,1268,968,1267],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/7618"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=7618"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/7618\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=7618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=7618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=7618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}