{"id":1205,"date":"2024-11-10T12:53:53","date_gmt":"2024-11-10T04:53:53","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1205\/"},"modified":"2024-11-10T12:53:53","modified_gmt":"2024-11-10T04:53:53","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8css%e5%b0%86%e8%83%8c%e6%99%af%e5%9b%be%e7%89%87%e8%ae%be%e7%bd%ae%e4%b8%ba%e6%b8%90%e5%8f%98%e6%95%88%e6%9e%9c%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1205\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528CSS\u5c06\u80cc\u666f\u56fe\u7247\u8bbe\u7f6e\u4e3a\u6e10\u53d8\u6548\u679c\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173029615990796.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528CSS\u5c06\u80cc\u666f\u56fe\u7247\u8bbe\u7f6e\u4e3a\u6e10\u53d8\u6548\u679c\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528CSS\u5c06\u80cc\u666f\u56fe\u7247\u8bbe\u7f6e\u4e3a\u6e10\u53d8\u6548\u679c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u7528\u5c06\u80cc\u666f\u56fe\u7247\u8bbe\u5b9a\u4e3a\u6e10\u53d8\u6548\u679c\uff1f<\/strong><\/p>\n<p>\u5728\u8bbe\u7f6e\u80cc\u666f\u56fe\u7247\u6e10\u8fdb\u6548\u679c\u65f6\u9047\u5230\u56f0\u96be\uff1f\u6211\u4eec\u6765\u6df1\u5165\u4e86\u89e3\u4e00\u4e0b\u5982\u4f55\u901a\u8fc7CSS filter\u5c5e\u6027\u5b9e\u73b0\u6b64\u6548\u679c\uff0c\u7279\u522b\u9002\u7528\u4e8eSVG\u683c\u5f0f\u7684\u56fe\u7247\u3002<\/p>\n<p><strong>CSS filter\u5c5e\u6027<\/strong><\/p>\n<p>CSS filter\u5c5e\u6027\u53ef\u7528\u4e8e\u5c06\u7279\u6b8a\u6548\u679c\u5e94\u7528\u4e8e\u56fe\u50cf\uff0c\u5176\u4e2d\u5305\u62ec\u5e94\u7528\u6e10\u53d8\u6548\u679c\u3002\u5b83\u63a5\u53d7SVG\u6e10\u53d8\u5b9a\u4e49\u4f5c\u4e3a\u53c2\u6570\uff0c\u8be5\u5b9a\u4e49\u6307\u5b9a\u4e86\u6e10\u53d8\u7684\u8d77\u70b9\u3001\u7ec8\u70b9\u548c\u989c\u8272\u3002<\/p>\n<p><strong>\u6e10\u53d8\u683c\u5f0f\u793a\u4f8b<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u4ee5\u4e0b\u662f\u5e94\u7528\u4e8eSVG\u56fe\u7247\u4e2d\u7684\u5f84\u5411\u6e10\u53d8\u683c\u5f0f\u793a\u4f8b\uff1a<\/p>\n<pre>filter: url(#gradient-id);\n\n@svg defs {\n  radialGradient id=\"gradient-id\" cx=\"50%\" cy=\"50%\" r=\"50%\"&gt;\n    &lt;stop offset=\"0%\" stop-color=\"#ff0000\" \/&gt;\n    &lt;stop offset=\"100%\" stop-color=\"#0000ff\" \/&gt;\n  &lt;\/radialGradient&gt;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6e10\u53d8\u4ece\u7ea2\u8272\uff08#ff0000\uff09\u5230\u84dd\u8272\uff08#0000ff\uff09\uff0c\u4ece\u56fe\u50cf\u4e2d\u5fc3\uff0850%, 50%\uff09\u5411\u5916\u8f90\u5c04\u3002<\/p>\n<p><strong>\u5e94\u7528\u6e10\u53d8\u5230\u80cc\u666f\u56fe\u7247<\/strong><\/p>\n<p>\u8981\u5c06\u4e0a\u8ff0\u6e10\u53d8\u5e94\u7528\u5230\u80cc\u666f\u56fe\u7247\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0bCSS\u4ee3\u7801\uff1a<\/p>\n<pre>background-image: url(my-image.svg);\nfilter: url(#gradient-id);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879<\/strong><\/p>\n<ul>\n<li>\u8be5\u65b9\u6cd5\u4ec5\u9002\u7528\u4e8eSVG\u683c\u5f0f\u7684\u56fe\u7247\u3002<\/li>\n<li>\u6e10\u53d8\u5b9a\u4e49\u5fc5\u987b\u5305\u542b\u5728 \u5143\u7d20\u7684 \u90e8\u5206\u4e2d\u3002 <\/li>\n<li>\u786e\u4fdd\u6e10\u53d8\u5b9a\u4e49\u5177\u6709\u552f\u4e00\u7684ID\uff0c\u4ee5\u9632\u6b62\u4e0e\u5176\u4ed6\u6e10\u53d8\u51b2\u7a81\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528CSS\u5c06\u80cc\u666f\u56fe\u7247\u8bbe\u7f6e\u4e3a\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\u7528\u5c06\u80cc\u666f\u56fe\u7247\u8bbe\u5b9a\u4e3a\u6e10\u53d8\u6548\u679c\uff1f \u5728\u8bbe\u7f6e\u80cc\u666f\u56fe\u7247\u6e10\u8fdb\u6548\u679c\u65f6\u9047\u5230\u56f0\u96be\uff1f\u6211\u4eec\u6765\u6df1\u5165\u4e86\u89e3\u4e00\u4e0b\u5982\u4f55\u901a\u8fc7CSS filter\u5c5e\u6027\u5b9e\u73b0\u6b64\u6548\u679c\uff0c\u7279\u522b\u9002\u7528\u4e8eSVG\u683c\u5f0f\u7684\u56fe\u7247\u3002 CSS filter\u5c5e\u6027 CSS filter\u5c5e\u6027\u53ef\u7528\u4e8e\u5c06\u7279\u6b8a\u6548\u679c\u5e94\u7528\u4e8e\u56fe\u50cf\uff0c\u5176\u4e2d\u5305\u62ec\u5e94\u7528\u6e10\u53d8\u6548\u679c\u3002\u5b83\u63a5\u53d7SVG\u6e10\u53d8\u5b9a\u4e49\u4f5c\u4e3a\u53c2\u6570\uff0c\u8be5\u5b9a\u4e49\u6307\u5b9a\u4e86\u6e10\u53d8\u7684\u8d77\u70b9\u3001\u7ec8\u70b9\u548c\u989c\u8272\u3002 \u6e10\u53d8\u683c\u5f0f\u793a\u4f8b \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4ee5\u4e0b\u662f\u5e94\u7528\u4e8eSVG\u56fe\u7247\u4e2d\u7684\u5f84\u5411\u6e10\u53d8\u683c\u5f0f\u793a\u4f8b\uff1a filter: url(#gradient-id); @svg defs { radialGradient id=&#8221;gradient-id&#8221; cx=&#8221;50%&#8221; cy=&#8221;50%&#8221; r=&#8221;50%&#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;\/radialGradient&gt; } \u767b\u5f55\u540e\u590d\u5236 \u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6e10\u53d8\u4ece\u7ea2\u8272\uff08#ff0000\uff09\u5230\u84dd\u8272\uff08#0000ff\uff09\uff0c\u4ece\u56fe\u50cf\u4e2d\u5fc3\uff0850%, 50%\uff09\u5411\u5916\u8f90\u5c04\u3002 \u5e94\u7528\u6e10\u53d8\u5230\u80cc\u666f\u56fe\u7247 \u8981\u5c06\u4e0a\u8ff0\u6e10\u53d8\u5e94\u7528\u5230\u80cc\u666f\u56fe\u7247\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0bCSS\u4ee3\u7801\uff1a background-image: url(my-image.svg); filter: url(#gradient-id); \u767b\u5f55\u540e\u590d\u5236 \u6ce8\u610f\u4e8b\u9879 \u8be5\u65b9\u6cd5\u4ec5\u9002\u7528\u4e8eSVG\u683c\u5f0f\u7684\u56fe\u7247\u3002 \u6e10\u53d8\u5b9a\u4e49\u5fc5\u987b\u5305\u542b\u5728 \u5143\u7d20\u7684 \u90e8\u5206\u4e2d\u3002 \u786e\u4fdd\u6e10\u53d8\u5b9a\u4e49\u5177\u6709\u552f\u4e00\u7684ID\uff0c\u4ee5\u9632\u6b62\u4e0e\u5176\u4ed6\u6e10\u53d8\u51b2\u7a81\u3002 \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528CSS\u5c06\u80cc\u666f\u56fe\u7247\u8bbe\u7f6e\u4e3a\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},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-1205","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1205","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=1205"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1205\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}