{"id":1190,"date":"2024-11-10T11:24:58","date_gmt":"2024-11-10T03:24:58","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1190\/"},"modified":"2024-11-10T11:24:58","modified_gmt":"2024-11-10T03:24:58","slug":"%e5%a6%82%e4%bd%95%e4%b8%ba-svg-%e5%9b%be%e7%89%87%e6%b7%bb%e5%8a%a0%e6%b8%90%e5%8f%98%e6%95%88%e6%9e%9c%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1190\/","title":{"rendered":"\u5982\u4f55\u4e3a SVG \u56fe\u7247\u6dfb\u52a0\u6e10\u53d8\u6548\u679c\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173028934436335.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4e3a SVG \u56fe\u7247\u6dfb\u52a0\u6e10\u53d8\u6548\u679c\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4e3a SVG \u56fe\u7247\u6dfb\u52a0\u6e10\u53d8\u6548\u679c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528  \u521b\u5efa\u80cc\u666f\u56fe\u7247\u6e10\u53d8\u6548\u679c\uff1f<\/strong><\/p>\n<p>\u6709\u7528\u6237\u54a8\u8be2\u5982\u4f55\u901a\u8fc7 CSS \u4e3a\u80cc\u666f\u56fe\u7247\u6dfb\u52a0\u6e10\u53d8\u6548\u679c\uff0c\u4f46\u6309\u7167\u6587\u7ae0\u6307\u5bfc\u7684\u65b9\u6cd5\u672a\u80fd\u6210\u529f\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<p>\u4e3a SVG \u683c\u5f0f\u7684\u56fe\u7247\u6dfb\u52a0\u6e10\u53d8\u6548\u679c\uff0c\u53ef\u4ee5\u4f7f\u7528 CSS filter \u6280\u672f\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u4f7f\u7528 \u6807\u7b7e\u521b\u5efa SVG \u56fe\u7247\u5143\u7d20\u3002 <\/li>\n<li>\u5728 \u5143\u7d20\u4e2d\uff0c\u5b9a\u4e49\u6e10\u53d8\u6548\u679c\u3002\u4f8b\u5982\uff1a <\/li>\n<\/ol>\n<pre>&lt;svg&gt;\n  &lt;defs&gt;\n    &lt;linearGradient id=\"gradient\"&gt;\n      &lt;stop offset=\"0%\" stop-color=\"#ff0000\" \/&gt;\n      &lt;stop offset=\"100%\" stop-color=\"#0000ff\" \/&gt;\n    &lt;\/linearGradient&gt;\n  &lt;\/defs&gt;\n  &lt;filter id=\"filter\"&gt;\n    &lt;feFlood flood-color=\"transparent\" result=\"flood\" \/&gt;\n    &lt;feComposite in=\"SourceGraphic\" in2=\"flood\" operator=\"in\" result=\"composite\" \/&gt;\n    &lt;feMerge&gt;\n      &lt;feMergeNode in=\"flood\" \/&gt;\n      &lt;feMergeNode in=\"composite\" --&gt;\n    &lt;\/feMerge&gt;\n  &lt;\/filter&gt;\n&lt;\/svg&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\u5c06 filter \u5f15\u7528\u5230\u80cc\u666f\u56fe\u7247\u4e2d\uff1a<\/li>\n<\/ol>\n<pre>background-image: url(image.svg);\nbackground-filter: url(#filter);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u6cd5\uff0c\u53ef\u4ee5\u4e3a SVG \u683c\u5f0f\u7684\u56fe\u7247\u6dfb\u52a0\u6e10\u53d8\u6548\u679c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4e3a SVG \u56fe\u7247\u6dfb\u52a0\u6e10\u53d8\u6548\u679c\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4f7f\u7528 \u521b\u5efa\u80cc\u666f\u56fe\u7247\u6e10\u53d8\u6548\u679c\uff1f \u6709\u7528\u6237\u54a8\u8be2\u5982\u4f55\u901a\u8fc7 CSS \u4e3a\u80cc\u666f\u56fe\u7247\u6dfb\u52a0\u6e10\u53d8\u6548\u679c\uff0c\u4f46\u6309\u7167\u6587\u7ae0\u6307\u5bfc\u7684\u65b9\u6cd5\u672a\u80fd\u6210\u529f\u3002 \u89e3\u51b3\u65b9\u6848\uff1a \u4e3a SVG \u683c\u5f0f\u7684\u56fe\u7247\u6dfb\u52a0\u6e10\u53d8\u6548\u679c\uff0c\u53ef\u4ee5\u4f7f\u7528 CSS filter \u6280\u672f\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a \u4f7f\u7528 \u6807\u7b7e\u521b\u5efa SVG \u56fe\u7247\u5143\u7d20\u3002 \u5728 \u5143\u7d20\u4e2d\uff0c\u5b9a\u4e49\u6e10\u53d8\u6548\u679c\u3002\u4f8b\u5982\uff1a &lt;svg&gt; &lt;defs&gt; &lt;linearGradient id=&#8221;gradient&#8221;&gt; &lt;stop offset=&#8221;0%&#8221; stop-color=&#8221;#ff0000&#8243; \/&gt; &lt;stop offset=&#8221;100%&#8221; stop-color=&#8221;#0000ff&#8221; \/&gt; &lt;\/linearGradient&gt; &lt;\/defs&gt; &lt;filter id=&#8221;filter&#8221;&gt; &lt;feFlood flood-color=&#8221;transparent&#8221; result=&#8221;flood&#8221; \/&gt; &lt;feComposite in=&#8221;SourceGraphic&#8221; in2=&#8221;flood&#8221; operator=&#8221;in&#8221; result=&#8221;composite&#8221; \/&gt; &lt;feMerge&gt; &lt;feMergeNode in=&#8221;flood&#8221; \/&gt; &lt;feMergeNode in=&#8221;composite&#8221; &#8211;&gt; &lt;\/feMerge&gt; &lt;\/filter&gt; &lt;\/svg&gt; \u767b\u5f55\u540e\u590d\u5236 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-1190","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=1190"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1190\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}