{"id":4089,"date":"2014-04-08T22:44:46","date_gmt":"2014-04-08T14:44:46","guid":{"rendered":"http:\/\/www.zhangxinxu.com\/wordpress\/?p=4089"},"modified":"2018-06-15T23:32:07","modified_gmt":"2018-06-15T15:32:07","slug":"animateion-line-drawing-svg-path-%e5%8a%a8%e7%94%bb-%e8%b7%af%e5%be%84","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2014\/04\/animateion-line-drawing-svg-path-%e5%8a%a8%e7%94%bb-%e8%b7%af%e5%be%84\/","title":{"rendered":"\u7eafCSS\u5b9e\u73b0\u5e05\u6c14\u7684SVG\u8def\u5f84\u63cf\u8fb9\u52a8\u753b\u6548\u679c"},"content":{"rendered":"<p>by <a href=\"http:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"http:\/\/www.zhangxinxu.com\/\">http:\/\/www.zhangxinxu.com<\/a><br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=4089\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=4089<\/a><\/p>\n<h3>\u4e00\u3001\u5e94\u8be5\u4eba\u4eba\u7686\u4f1a\u7684\u57fa\u7840\u6280\u672f<\/h3>\n<p>\u7b80\u800c\u8a00\u4e4b\uff0c\u5c31\u662f\u8ba9SVG\u7684\u63cf\u8fb9\u50cf\u662f\u6709\u4eba\u7ed8\u5236\u4e00\u6837\u7684\u52a8\u753b\u6548\u679c\u3002<\/p>\n<p>\u56fd\u5916\u5f88\u591a\u76f8\u5173\u4ecb\u7ecd\u7684\u6587\u7ae0\uff0c\u6765\u770b\u770b\u4e00\u4e9b\u6548\u679cgif\u5427~<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201404\/2014-04-08_24-gift.gif\" width=\"566\" height=\"220\" alt=\"\u8def\u5f84\u7ed8\u5236gif\u52a8\u753b\u622a\u56fe\" class=\"alignnone\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201404\/2014-04-08_15-27-19.gif\" width=\"488\" height=\"187\" alt=\"svg\u7ebf\u6761\u52a8\u753bgif\" class=\"alignnone\" \/><\/p>\n<p>\u6211\u81f3\u5c11\u770b\u5230\u4e864\u7bc7\u5916\u6587\u5bf9\u6b64\u6280\u672f\u4ecb\u7ecd\uff08\u53c2\u89c1\u6587\u672b\u53c2\u8003\u6587\u7ae0\uff09\uff0c\u89c9\u5f97\u633a\u6709\u610f\u601d\uff0c\u4e5f\u5f88\u597d\u5165\u95e8\uff0c\u53ef\u4ee5\u4e0d\u4f9d\u8d56JavaScript\uff0c\u6545\u79fb\u82b1\u63a5\u6728\uff0c\u501f\u82b1\u732e\u4f5b\uff0c\u4ee5\u81ea\u5df1\u7684\u7406\u89e3\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u4e0b\u3002<\/p>\n<h3>\u4e8c\u3001\u6548\u679c\u5148\u884c\uff0c\u5174\u8da3\u6311\u8d77<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201404\/2014-04-08_16-30-19.gif\" width=\"589\" height=\"224\" alt=\"\u540d\u5b57\u7ebf\u6761gif\u52a8\u753b\" class=\"mt10\" \/><\/p>\n<p>\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a class=\"a_link\" href=\"http:\/\/www.zhangxinxu.com\/study\/201404\/svg-path-animation-my-name-zhangxinxu.html\" target=\"_blank\">\u5e05\u6c14\u7684\u7b7e\u540d\u52a8\u753bdemo<\/a><\/p>\n<h3>\u4e09\u3001\u4f60\u9700\u8981\u77e5\u9053\u7684\u57fa\u7840\u77e5\u8bc6<\/h3>\n<p>SVG\u4e2d\u6709\u4e2a\u6bd4\u8f83\u91cd\u8981\u7684\u5c5e\u6027\u5206\u652f\uff0c\u540d\u4e3a<code>stroke<\/code>, \u4e2d\u6587\u8f6f\u4ef6\u4e2d\u79f0\u4e4b\u4e3a\u201c\u63cf\u8fb9\u201d\u3002<\/p>\n<p><code>stroke<\/code>\u9664\u4e86\u81ea\u5df1\uff0c\u8fd8\u6709\u5176\u4ed6\u8bf8\u591a\u5144\u5f1f\u59d0\u59b9\uff0c\u6765\uff0c\u7ad9\u8d77\u6765\u7ed9\u5927\u5bb6\u7785\u7785\uff1a<\/p>\n<ul>\n<li><code>stroke<\/code> \u8868\u793a\u63cf\u8fb9\u989c\u8272\u3002\u8fd9\u5f88\u6709\u610f\u601d\uff0c\u540d\u5b57\u4e0d\u662f<code><del datetime=\"2014-04-08T06:56:30+00:00\">stroke-color<\/del><\/code>, \u800c\u5c31\u662f\u5355\u7eaf\u7684<code>stroke<\/code>. \u5176\u503c\uff0c\u5b98\u65b9\u79f0\u4e4b\u4e3a&#8221;<code>paint<\/code>&#8220;\uff0c\u6211\u5c31\u4e0d\u4e0a\u6881\u5c0f\u4e11\u822c\u7ffb\u8bd1\u4e86\u3002\u4e00\u822c\u6709\u5982\u4e0b\u7c7b\u578b\u503c\uff1a<code>none<\/code>, <code>currentColor<\/code>, <code>&lt;color&gt;<\/code>. <code>none<\/code>\u8868\u793a\u6ca1\u6709\u989c\u8272\uff0c<code>&lt;color&gt;<\/code>\u5c31\u662f\u6211\u4eec\u5e38\u89c4\u7684\u989c\u8272\u503c\u3002RGBA, HSBA\u90fd\u652f\u6301\u3002<code>currentColor<\/code>\u7565\u9ad8\u6df1\uff0c\u6211\u770b\u4e86\u4e0b<a href=\"http:\/\/www.w3.org\/TR\/SVG11\/painting.html#SpecifyingPaint\">\u5b98\u65b9\u6587\u6863<\/a>\uff0c\u4e2a\u4eba\u7406\u89e3\u4e3a\uff1a\u5171\u4eab\u7236\u7ea7\u4f46\u4e0d\u8d8a\u8fc7SVG\u5143\u7d20\u7684XML\u4e2d<code>color<\/code>(style\u4e2d\u7684)\u503c\uff1b\u53ef\u4ee5\u8ba9\u8def\u5f84\u7ed8\u5236\u7684\u6587\u5b57\u76f4\u63a5\u7ee7\u627f\u7236\u6807\u7b7e\u7684<code>color<\/code>\u989c\u8272\u503c\u3002<\/li>\n<li><code>stroke-width<\/code> \u8868\u793a\u63cf\u8fb9\u7684\u7c97\u7ec6\u3002<\/li>\n<li><code>stroke-linecap<\/code> \u8868\u793a\u63cf\u8fb9\u7aef\u70b9\u8868\u73b0\u65b9\u5f0f\u3002\u53ef\u7528\u503c\u6709\uff1a<code>butt<\/code>, <code>round<\/code>, <code>square<\/code>, <code>inherit<\/code>. \u8868\u73b0\u5982\u4e0b\u56fe\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201404\/linecap.png\" width=\"454\" height=\"76\" alt=\"stroke-linecap\u7684\u4e0d\u540c\u503c\u7684\u8868\u73b0\" class=\"mt10\" \/><\/p>\n<\/li>\n<li><code>stroke-linejoin<\/code> \u8868\u793a\u63cf\u8fb9\u8f6c\u89d2\u7684\u8868\u73b0\u65b9\u5f0f\u3002\u53ef\u7528\u503c\u6709\uff1a<code>miter<\/code>, <code>round<\/code>, <code>bevel<\/code>, <code>inherit<\/code>. \u8868\u73b0\u5982\u4e0b\u56fe\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201404\/linejoin.png\" width=\"454\" height=\"133\" alt=\"stroke-linejoin\u4e0d\u540c\u503c\u7684\u8868\u73b0\" class=\"alignnone\" \/><\/li>\n<li><code>stroke-miterlimit<\/code> \u8868\u793a\u63cf\u8fb9\u76f8\u4ea4\uff08\u9510\u89d2\uff09\u7684\u8868\u73b0\u65b9\u5f0f\u3002\u9ed8\u8ba4\u5927\u5c0f\u662f<code>4<\/code>. \u4ec0\u4e48\u659c\u89d2\u8f6c\u659c\u9762\u7684\u89d2\u5ea6\u635f\u8017\u4e4b\u7c7b\u7684\u610f\u601d\uff0c\u503c\u8d8a\u5927\uff0c\u635f\u8017\u8d8a\u5c0f\u3002\u5177\u4f53\u5e72\u561b\u7684\uff0c\u6211\u81ea\u5df1\u4e5f\u4e0d\u786e\u5b9a\u3002\u5927\u5bb6\u53ef\u67e5\u67e5\u5176\u4ed6\u8d44\u6599\u3002<\/li>\n<li><code>stroke-dasharray<\/code> \u8868\u793a\u865a\u7ebf\u63cf\u8fb9\u3002\u53ef\u9009\u503c\u4e3a\uff1a<code>none<\/code>, <code>&lt;dasharray&gt;<\/code>, <code>inherit<\/code>. \u5176\u4e2d\uff0c<code>none<\/code>\u8868\u793a\u4e0d\u662f\u865a\u7ebf\uff1b<code>&lt;dasharray&gt;<\/code>\u4e3a\u4e00\u4e2a\u9017\u53f7\u6216\u7a7a\u683c\u5206\u9694\u7684\u6570\u503c\u5217\u8868\u3002\u8868\u793a\u5404\u4e2a\u865a\u7ebf\u7aef\u7684\u957f\u5ea6\u3002\u53ef\u4ee5\u662f\u56fa\u5b9a\u7684\u957f\u5ea6\u503c\uff0c\u4e5f\u53ef\u4ee5\u662f\u767e\u5206\u6bd4\u503c\uff1b<code>inherit<\/code>\u8868\u7ee7\u627f\u3002<\/li>\n<li><code>stroke-dashoffset<\/code> \u8868\u793a\u865a\u7ebf\u7684\u8d77\u59cb\u504f\u79fb\u3002\u53ef\u9009\u503c\u4e3a\uff1a<code>&lt;percentage&gt;<\/code>, <code>&lt;length&gt;<\/code>, <code>inherit<\/code>. \u767e\u5206\u6bd4\u503c\uff0c\u957f\u5ea6\u503c\uff0c\u7ee7\u627f\u3002<\/li>\n<li><code>stroke-opacity<\/code> \u8868\u793a\u63cf\u8fb9\u900f\u660e\u5ea6\u3002\u9ed8\u8ba4\u662f<code>1<\/code>. <\/li>\n<\/ul>\n<p>\u800c\uff0c\u4e0e\u672c\u6587\u76f8\u5173\u7684\u52a8\u753b\u6548\u679c\u76f8\u5173\u7684\u5c31\u662f<code>stroke-dasharray<\/code>\u548c<code>stroke-dashoffset<\/code>\u7740\u4e24\u5144\u5f1f\u3002<\/p>\n<h3>\u56db\u3001stroke-dasharray\u548cstroke-dashoffset<\/h3>\n<p>\u4e3a\u4e86\u65b9\u4fbf\u8bf4\u660e\uff0c\u51cf\u5c11\u5e72\u6270\uff0c\u6211\u4eec\u62ff\u4e00\u6761\u76f4\u7ebf\u7092\u4e2a\u677f\u6817\uff0c\u5982\u4e0b\uff1a<br \/>\n<svg id=\"svgForStroke\" width=\"400\" height=\"200\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><g><line fill=\"none\" stroke=\"#000000\" stroke-width=\"5\" stroke-dasharray=\"null\" stroke-linejoin=\"null\" stroke-linecap=\"round\" x1=\"90\" y1=\"90\" x2=\"330\" y2=\"90\"\/><\/g><\/svg><\/p>\n<p>\u70b9\u51fb\u4e0b\u9762\u7684\u6ed1\u5757\uff08\u6216\u8f93\u5165\u6570\u503c\uff09\u4f53\u9a8c\u4e0b\uff1a<br \/>\n<strong>stroke-dasharray:<\/strong> <input type=range min=0 max=400 value=0 size=30 onChange='javascript:document.querySelector(\"#svgForStroke line\").setAttribute(\"stroke-dasharray\", this.value)';><br \/>\n<strong>stroke-dashoffset:<\/strong> <input type=range min=0 max=400 value=0 size=30 onChange='javascript:document.querySelector(\"#svgForStroke line\").setAttribute(\"stroke-dashoffset\", this.value)';><\/p>\n<p>HTML\u4ee3\u7801\u4e3a\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>&lt;svg id=\"svgForStroke\" width=\"400\" height=\"200\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n &lt;g>\n  &lt;line fill=\"none\" stroke=\"#000000\" stroke-width=\"5\" stroke-dasharray=\"null\" stroke-linejoin=\"null\" stroke-linecap=\"round\" x1=\"0\" y1=\"90\" x2=\"400\" y2=\"90\"\/>\n &lt;\/g>\n&lt;\/svg><\/pre>\n<\/div>\n<p>\u79fb\u52a8\u6ed1\u5757\u65f6\u5019\uff08\u6216\u6587\u672c\u6846\u8f93\u5165\uff09\u65f6\u5019\uff0c\u901a\u8fc7<code>setAttribute<\/code>\u65b9\u6cd5\u8bbe\u7f6e<code>&lt;line&gt;<\/code>\u8282\u70b9\u5143\u7d20\u7684<code>stroke-dasharray<\/code>\u548c<code>stroke-dashoffset<\/code>\u503c\uff0c\u8fbe\u5230\u4e86\u4e0a\u9762\u7684\u6548\u679c\u3002<span class=\"s\">\/\/zxx: \u5982\u679c\u60a8\u53d1\u73b0\u79fb\u9001\u6ed1\u5757\u6ca1\u6709\u6548\u679c\uff0c\u53ef\u80fd\u60a8\u8bbf\u95ee\u7684\u4e0d\u662f\u539f\u51fa\u5904\u3002<\/span><\/p>\n<p><strong>\u4e00\u4e2a\u7279\u6b8a\u60c5\u51b5<\/strong><br \/>\n\u6211\u4eec\u73b0\u5728\u90fd\u8bd5\u60f3\u4e00\u4e0b\uff0c\u5982\u679c<code>stroke-dasharray<\/code>\u548c<code>stroke-dashoffset<\/code>\u503c\u90fd\u5f88\u5927\uff0c\u8d85\u8fc7\u4e86\u63cf\u8fb9\u8def\u5f84\u7684\u603b\u957f\u5ea6\uff0c\u4f1a\u600e\u4e48\u6837\uff1f<\/p>\n<p>\u7528\u4e2d\u6587\u89e3\u91ca\u5c31\u662f\uff0c\u4e00\u6839\u706b\u817f\u80a012\u5398\u7c73\uff0c\u8981\u5728\u4e0a\u9762\u753b\u865a\u7ebf\uff0c\u865a\u7ebf\u95f4\u9694\u670915\u5398\u7c73\uff0c\u5982\u679c\u6ca1\u6709<code>dashoffset<\/code>\uff0c\u5219\u706b\u817f\u80a0\u524d\u976215\u5398\u7c73\u4f1a\u88ab\u8fa3\u6912\u9171\u8986\u76d6\uff01\u5b9e\u9645\u4e0a\u53ea\u670912\u5398\u7c73\uff0c\u56e0\u6b64\uff0c\u6211\u4eec\u770b\u5230\u7684\u662f\u6574\u4e2a\u706b\u817f\u80a0\u90fd\u6709\u8fa3\u6912\u9171\u3002\u73b0\u5728\uff0c<code>dashoffset<\/code>\u4e5f\u662f15\u5398\u7c73\uff0c\u4e5f\u5c31\u662f\u865a\u7ebf\u8981\u5f80\u540e\u504f\u79fb15\u5398\u7c73\uff0c\u7ed3\u679c\uff0c\u8fa3\u6912\u9171\u8981\u62b9\u5728\u706b\u817f\u80a0\u4e4b\u5916\uff0c\u4e5f\u5c31\u662f\u706b\u817f\u80a0\u4e0a\u4ec0\u4e48\u8fa3\u6912\u9171\u4e5f\u6ca1\u6709\u3002\u5982\u679c\u6362\u6210\u4e0a\u9762\u7684\u76f4\u7ebfSVG\uff0c\u4e5f\u5c31\u662f\u76f4\u7ebf\u770b\u4e0d\u89c1\u4e86\u3002\u6211\u4eec\u628a<code>dashoffset<\/code>\u503c\u9010\u6e10\u53d8\u5c0f\uff0c\u5219\u4f1a\u53d1\u73b0\uff0c\u706b\u817f\u80a0\u4e0a\u7684\u8fa3\u6912\u9171\u4e00\u70b9\u4e00\u70b9\u51fa\u73b0\u4e86\uff0c\u597d\u50cf\u8fa3\u6912\u9171\u4ece\u706b\u817f\u80a0\u6839\u90e8\u6d82\u62b9\u4e0a\u53bb\u4e00\u6837\u3002<\/p>\n<p>\u4e0a\u9762\u7684\u4e24\u4e2a\u6ed1\u5757\u90fd\u53f3\u6ed1\u5230\u5e95\uff0c\u7136\u540e\u4e0b\u9762\u7684\u6ed1\u5757\u5f80\u5de6\u6162\u6162\u6ed1\uff08\u8bf7\u4f7f\u7528\u652f\u6301<code>type=range<\/code>\u7684\u6d4f\u89c8\u5668\uff09\uff0c\u60a8\u4f1a\u770b\u5230\u76f4\u7ebf\u6162\u6162\u51fa\u6765\u4e86\uff0c\u8fd9\u5c31\u662fSVG\u8def\u5f84\u7ed8\u5236\u52a8\u753b\u7684\u539f\u7406\u3002<\/p>\n<h3>\u4e94\u3001CSS3 animation\u7684\u652f\u6301<\/h3>\n<p>\u5185\u8054SVG\u7684\u5f3a\u5927\u4e4b\u5904\u5728\u4e8e\uff0c\u5176\u672c\u8eab\u4e5f\u662f\u4e2aHTML\u5143\u7d20\uff0c\u80fd\u88abCSS\u5c5e\u6027\u63a7\u5236\uff0c\u5904\u7406\u4f20\u7edf\u7684\u9ad8\u5bbd\u5b9a\u4f4d\u3001\u8fb9\u6846\u80cc\u666f\u8272\u7b49\uff0cSVG\u81ea\u8eab\u7684\u4e00\u4e9b\u7279\u6b8a\u5c5e\u6027\u4e5f\u80fd\u88abCSS\u652f\u6301\uff0c\u751a\u81f3\u5728CSS3 animation\u52a8\u753b\u4e2d\u3002<\/p>\n<p>\u4e8e\u662f\uff0c\u6211\u4eec\u4e0a\u9762\u63a2\u8ba8\u7684SVG\u63cf\u8fb9\u52a8\u753b\u6548\u679c\u80fd\u591f\u8f7b\u677e\u4f7f\u7528CSS3 animation\u5b9e\u73b0\uff0c\u65e0\u9700\u4efb\u4f55JavaScript\uff0c\u8fd9\u5c31\u662f\u4e00\u5f00\u59cbDemo\u9875\u9762\u7684\u5b9e\u73b0\u3002<\/p>\n<p>\u5176CSS\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>path {\n  stroke-dasharray: 1000;\n  stroke-dashoffset: 1000;\n  animation: dash 5s linear infinite;\n}\n\n@keyframes dash {\n  to {\n    stroke-dashoffset: 0;\n  }\n}<\/pre>\n<\/div>\n<p><code>1000<\/code>\u6ca1\u6709\u4ec0\u4e48\u7279\u6b8a\u542b\u4e49\uff0c\u53ea\u662f\u8db3\u591f\u5927\uff0c\u4fdd\u8bc1\u6bd4\u6bd4\u6bcf\u4e2a\u8def\u5f84\u7684\u957f\u5ea6\u5927\u5373\u53ef\uff0c\u4f60\u4e5f\u53ef\u4ee5\u662f<code>1500<\/code>\uff0c\u533a\u522b\u5c31\u662f\u63cf\u8fb9\u901f\u5ea6\u66f4\u5feb\u4e00\u70b9\u3002<\/p>\n<p>\u5c5e\u6027CSS3 animation\u7684\u5c0f\u4f19\u4f34\u5e94\u8be5\u4e00\u770b\u5c31\u770b\u51fa\u4e0a\u9762\u4ee3\u7801\u7684\u542b\u4e49\u7684\uff0c<code>5<\/code>\u79d2\u52a8\u753b\uff0c<code>stroke-dashoffset<\/code>\u4ece<code>1000<\/code>\u5230<code>0<\/code>. \u63cf\u8fb9\u52a8\u753b\u5f62\u6210\u3002<\/p>\n<p>\u4ee5\u4e0aCSS\u4ee3\u7801\u51e0\u4e4e\u53ef\u4ee5\u901a\u7528\u3002\u65e0\u8bba\u4f60\u7684SVG\u8def\u5f84\u591a\u4e48\u590d\u6742\uff0c\u90fd\u80fd\u4ee5\u63cf\u8fb9\u52a8\u753b\u5f62\u5f0f\u5448\u73b0\u3002\u6839\u636e\u81ea\u5df1\u7684\u6d4b\u8bd5\uff0cIE10+\u4e0b\u6ca1\u6709\u52a8\u753b\u6548\u679c\uff0c\u4e0d\u662fCSS\u4e0d\u652f\u6301SVG\u7684<code>stroke<\/code>\u76f8\u5173\u5c5e\u6027\uff0c\u800c\u662f<code>animation<\/code>\u4e2d\u4e0d\u652f\u6301<code>stroke<\/code>\u76f8\u5173\u5c5e\u6027\u7684\u52a8\u753b\u3002<\/p>\n<p>\u4ee5\u4e0a\u6548\u679c\u6709\u4ec0\u4e48\u7528\u7684\uff0c\u6211\u8bd5\u60f3\u4e86\u4ee5\u4e0b\u4e00\u4e9b\u573a\u666f\uff1a\u6f14\u793a\u65f6\u5019\u5206\u6b65\u5c55\u793a\u4e00\u4e9b\u8981\u70b9\uff1b\u6216\u8005\u56fe\u7247\u7b49<code>hover<\/code>\u63cf\u8fb9\u6548\u679c\uff1b\u6216\u8005\u7f51\u7ad9tip\u6ce8\u610f\u9879\u7684\u7bad\u5934\u5f15\u5bfc\u63d0\u793a\u6548\u679c\u7b49\uff0c\u90fd\u5f88\u6709\u7528\u3002\u6280\u672f+\u4f60\u8111\u4e2d\u4e0d\u65ad\u7684\u521b\u610f\uff0c\u624d\u6709\u7cbe\u5f69\u7eb7\u5448\u7684\u521b\u65b0\u4f53\u9a8c\u3002<\/p>\n<h3>\u516d\u3001\u8def\u5f84\u7684\u957f\u5ea6<\/h3>\n<p>\u5982\u679c\u60a8\u60f3\u77e5\u9053\u8def\u5f84\uff0c\u6216\u7ebf\u6761\u7684\u51c6\u786e\u957f\u5ea6\u3002\u53ef\u80fd\u9700\u8981\u501f\u52a9JavaScript\uff0c\u7c7b\u4f3c\u4e0b\u9762\u7684\u4ee3\u7801\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>var path = document.querySelector('path');\nvar length = path.getTotalLength();<\/pre>\n<\/div>\n<p>\u4ee5\u4e0a\uff0c\u795d\u4f60\u597d\u8fd0\uff01<img decoding=\"async\" src=\"http:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/14.gif\" align=\"absmiddle\"><\/p>\n<h3>\u4e03\u3001\u53c2\u8003\u6587\u7ae0<\/h3>\n<ul>\n<li><a href=\"http:\/\/product.voxmedia.com\/2013\/11\/25\/5426880\/polygon-feature-design-svg-animations-for-fun-and-profit\">Polygon feature design: SVG animations for fun and profit<\/a><\/li>\n<li><a href=\"http:\/\/24ways.org\/2013\/animating-vectors-with-svg\/\">Animating Vectors with SVG<\/a><\/li>\n<li><a href=\"http:\/\/css-tricks.com\/svg-line-animation-works\/\">How SVG Line Animation Works<\/a><\/li>\n<li><a href=\"http:\/\/jakearchibald.com\/2013\/animated-line-drawing-svg\/\">Animated line drawing in SVG<\/a><\/li>\n<li><a href=\"http:\/\/www.w3.org\/TR\/SVG11\/painting.html#StrokeProperties\">W3 &#8211; Stroke Properties<\/a><\/li>\n<\/ul>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u5305\u542b\u811a\u672c\u884c\u4e3a\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=4089\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=4089<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u5c5e\u4e8e\u7b80\u5355\u5b9e\u7528\u7684\u57fa\u7840\u6280\u672f\u79d1\u666e\u3002\u6709\u4e30\u5bcc\u7684gif\u52a8\u753b\u6f14\u793a\uff0c\u6709demo\uff0c\u6709\u622a\u56fe\u4ee5\u53ca\u5fc5\u8981\u7684\u6e90\u4ee3\u7801\u5c55\u793a\uff0c\u8fd8\u6709\u5b98\u65b9\u6587\u6863\u91ca\u4e49\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":[895],"tags":[531,910,912,911,642,204],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/4089"}],"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=4089"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/4089\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=4089"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=4089"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=4089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}