{"id":2314,"date":"2017-11-11T13:49:57","date_gmt":"2017-11-11T05:49:57","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=2314"},"modified":"2017-11-11T13:49:57","modified_gmt":"2017-11-11T05:49:57","slug":"svg%e5%ae%9e%e7%8e%b0%e5%a4%9a%e5%bd%a9%e5%9c%86%e7%8e%af%e5%80%92%e8%ae%a1%e6%97%b6%e6%95%88%e6%9e%9c","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=2314","title":{"rendered":"SVG\u5b9e\u73b0\u591a\u5f69\u5706\u73af\u5012\u8ba1\u65f6\u6548\u679c"},"content":{"rendered":"<p>\n\t\u5706\u73af\u5012\u8ba1\u65f6\u6211\u4eec\u7ecf\u5e38\u89c1\u5230\uff0c\u5b9e\u73b0\u7684\u65b9\u6cd5\u4e5f\u6709\u5f88\u591a\u79cd\u3002\u4f46\u662f\u672c\u6587\u5c06\u4ecb\u7ecd\u4e00\u79cd\u5168\u65b0\u7684\u5b9e\u73b0\u65b9\u5f0f\uff0c\u4f7f\u7528<a href=\"https:\/\/www.xttblog.com\/?tag=SVG\" name=\"SVG\" target=\"_blank\" title=\"SVG\">SVG<\/a>\u6765\u5b9e\u73b0\u5012\u8ba1\u65f6\u529f\u80fd\u3002\n<\/p>\n<p>\n\t\u672c\u6587\u4e3b\u8981\u7528\u5230\u4e86<a href=\"https:\/\/www.xttblog.com\/?tag=SVG\" name=\"SVG\" target=\"_blank\" title=\"SVG\">SVG<\/a>\u7684stroke-dasharray\u548cstroke-dashoffset\u7279\u6027\u3002\u4e0b\u56fe\u662f\u5012\u8ba1\u65f6\u8fd0\u884c\u6548\u679c\uff1a\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"SVG\u5012\u8ba1\u65f6\u6848\u4f8b\" src=\"http:\/\/img.bbs.csdn.net\/upload\/201711\/11\/1510378929_547868.png\" style=\"width: 405px;height: 404px\" \/>\n<\/p>\n<p>\n\t\u4e0b\u9762\u8bf4\u8bf4\u76f8\u5173\u7684\u5b9e\u73b0\u4ee3\u7801\u3002<a href=\"https:\/\/www.xttblog.com\/?tag=css3\" name=\"css3\" target=\"_blank\" title=\"css3\">css<\/a>\u5b9e\u73b0\u4ee3\u7801\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:css;\">\r\nsvg {\r\n    transform: rotate(-0.05deg);\r\n}\r\ncircle {\r\n    transition: stroke-dasharray .2s;\r\n}\r\n.time-count-x {\r\n    line-height: 1.5;\r\n    position: relative;\r\n}\r\n.time-second {\r\n    position: absolute;\r\n    top: 50%; left: 0; right: 0;\r\n    margin-top: -.75em;\r\n    text-align: center;\r\n    font-size: 100px;\r\n}<\/pre>\n<p>\n\t\u76f8\u5173<a href=\"https:\/\/www.xttblog.com\/?tag=html5\" name=\"html5\" target=\"_blank\" title=\"html5\">html<\/a>\u4ee3\u7801\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;div id=&quot;timeCountX&quot; class=&quot;time-count-x&quot;&gt;\r\n    &lt;svg width=&quot;440&quot; height=&quot;440&quot; viewBox=&quot;0 0 440 440&quot; class=&quot;center&quot;&gt;\r\n        &lt;defs&gt;\r\n            &lt;linearGradient x1=&quot;1&quot; y1=&quot;0&quot; x2=&quot;0&quot; y2=&quot;0&quot; id=&quot;gradient1&quot;&gt;\r\n                &lt;stop offset=&quot;0%&quot; stop-color=&quot;#e52c5c&quot;&gt;&lt;\/stop&gt;\r\n                &lt;stop offset=&quot;100%&quot; stop-color=&quot;#ab5aea&quot;&gt;&lt;\/stop&gt;\r\n            &lt;\/linearGradient&gt;\r\n           &lt;linearGradient x1=&quot;1&quot; y1=&quot;0&quot; x2=&quot;0&quot; y2=&quot;0&quot; id=&quot;gradient2&quot;&gt;\r\n                &lt;stop offset=&quot;0%&quot; stop-color=&quot;#4352f3&quot;&gt;&lt;\/stop&gt;\r\n                &lt;stop offset=&quot;100%&quot; stop-color=&quot;#ab5aea&quot;&gt;&lt;\/stop&gt;\r\n            &lt;\/linearGradient&gt;\r\n        &lt;\/defs&gt;\r\n        &lt;g transform=&quot;matrix(0,-1,1,0,0,440)&quot;&gt;\r\n            &lt;circle cx=&quot;220&quot; cy=&quot;220&quot; r=&quot;170&quot; stroke-width=&quot;50&quot; stroke=&quot;#f0f1f5&quot; fill=&quot;none&quot; stroke-dasharray=&quot;1069 1069&quot;&gt;&lt;\/circle&gt;\r\n            &lt;circle cx=&quot;220&quot; cy=&quot;220&quot; r=&quot;170&quot; stroke-width=&quot;50&quot; stroke=&quot;url(&#039;#gradient1&#039;)&quot; fill=&quot;none&quot; stroke-dasharray=&quot;1069 1069&quot;&gt;&lt;\/circle&gt;\r\n            &lt;circle cx=&quot;220&quot; cy=&quot;220&quot; r=&quot;170&quot; stroke-width=&quot;50&quot; stroke=&quot;url(&#039;#gradient2&#039;)&quot; fill=&quot;none&quot; stroke-dasharray=&quot;534.5 1069&quot;&gt;&lt;\/circle&gt;\r\n        &lt;\/g&gt;\r\n    &lt;\/svg&gt;\r\n    &lt;span id=&quot;timeSecond&quot; class=&quot;time-second&quot;&gt;&lt;\/span&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>\n\t\u6700\u540e\u662f\u76f8\u5173<a href=\"https:\/\/www.xttblog.com\/?tag=javascript\" name=\"javascript\" target=\"_blank\" title=\"javascript\">JavaScript<\/a>\u4ee3\u7801\uff1a\n<\/p>\n<pre class=\"brush:jscript;\">\r\nvar eleCircles=document.querySelectorAll(&quot;#timeCountX circle&quot;);\r\nvar eleTimeSec=document.getElementById(&quot;timeSecond&quot;);\r\nvar perimeter=Math.PI*2*170;\r\nvar circleInit=function(){\r\n\tif(eleCircles[1]){\r\n\t\teleCircles[1].setAttribute(&quot;stroke-dasharray&quot;,&quot;1069 1069&quot;)\r\n\t}\r\n\tif(eleCircles[2]){\r\n\t\teleCircles[2].setAttribute(&quot;stroke-dasharray&quot;,perimeter\/2+&quot; 1069&quot;)\r\n\t}\r\n\teleTimeSec.innerHTML=&quot;&quot;\r\n};\r\nvar timerTimeCount=null;\r\nvar fnTimeCount=function(b){\r\n\tif(timerTimeCount){\r\n\t\treturn\r\n\t}\r\n\tvar b=b||10;\r\n\tvar a=function(){\r\n\t\tvar c=b\/10;\r\n\t\tif(eleCircles[1]){\r\n\t\t\teleCircles[1].setAttribute(&quot;stroke-dasharray&quot;,perimeter*c+&quot; 1069&quot;)\r\n\t\t}\r\n\t\tif(eleCircles[2]&amp;&amp;b&lt;=5){\r\n\t\t\teleCircles[2].setAttribute(&quot;stroke-dasharray&quot;,perimeter*c+&quot; 1069&quot;)\r\n\t\t}\r\n\t\tif(eleTimeSec){\r\n\t\t\teleTimeSec.innerHTML=b\r\n\t\t}\r\n\t\tb--;\r\n\t\tif(b&lt;0){\r\n\t\t\tclearInterval(timerTimeCount);\r\n\t\t\ttimerTimeCount=null;\r\n\t\t\talert(&quot;\u65f6\u95f4\u5230\uff01&quot;);\r\n\t\t\tcircleInit()\r\n\t\t}\r\n\t};\r\n\ta();\r\n\ttimerTimeCount=setInterval(a,1000)\r\n};\r\nfnTimeCount();<\/pre>\n<p>\n\t\u6574\u4e2a\u6848\u4f8b\u7684\u4ee3\u7801\u975e\u5e38\u5c11\uff0c\u6709\u559c\u6b22\u7684\u670b\u53cb\u53ef\u4ee5\u5c06\u4ee3\u7801\u4fdd\u5b58\u5230<a href=\"https:\/\/www.xttblog.com\/?tag=html5\" name=\"html5\" target=\"_blank\" title=\"html5\">html<\/a>\u4e2d\uff0c\u8fd0\u884c\u4e00\u4e0b\uff0c\u4f53\u9a8c\u4f53\u9a8c\u5b9e\u9645\u6548\u679c\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=2314\">SVG\u5b9e\u73b0\u591a\u5f69\u5706\u73af\u5012\u8ba1\u65f6\u6548\u679c<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u5706\u73af\u5012\u8ba1\u65f6\u6211\u4eec\u7ecf\u5e38\u89c1\u5230\uff0c\u5b9e\u73b0\u7684\u65b9\u6cd5\u4e5f\u6709\u5f88\u591a\u79cd\u3002\u4f46\u662f\u672c\u6587\u5c06\u4ecb\u7ecd\u4e00\u79cd\u5168\u65b0\u7684\u5b9e\u73b0\u65b9\u5f0f\uff0c\u4f7f\u7528SVG\u6765\u5b9e\u73b0\u5012\u8ba1\u65f6\u529f\u80fd\u3002  [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[814,1106,52],"class_list":["post-2314","post","type-post","status-publish","format-standard","hentry","category-html5","tag-css3","tag-javascript","tag-svg"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2314","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2314"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2314\/revisions"}],"predecessor-version":[{"id":2315,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2314\/revisions\/2315"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}