{"id":27443,"date":"2024-11-24T15:30:35","date_gmt":"2024-11-24T07:30:35","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27443\/"},"modified":"2024-11-24T15:30:35","modified_gmt":"2024-11-24T07:30:35","slug":"css-%e6%8c%96%e7%bc%ba%e5%8f%a3%e6%95%88%e6%9e%9c%ef%bc%9amask-composite-%e5%b1%9e%e6%80%a7%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e4%bc%98%e9%9b%85%e7%9a%84%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27443\/","title":{"rendered":"CSS \u6316\u7f3a\u53e3\u6548\u679c\uff1amask-composite \u5c5e\u6027\u5982\u4f55\u5b9e\u73b0\u4f18\u96c5\u7684\u89e3\u51b3\u65b9\u6848\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173124523560302.jpg\" class=\"aligncenter\" title=\"CSS \u6316\u7f3a\u53e3\u6548\u679c\uff1amask-composite \u5c5e\u6027\u5982\u4f55\u5b9e\u73b0\u4f18\u96c5\u7684\u89e3\u51b3\u65b9\u6848\uff1f\u63d2\u56fe\" alt=\"CSS \u6316\u7f3a\u53e3\u6548\u679c\uff1amask-composite \u5c5e\u6027\u5982\u4f55\u5b9e\u73b0\u4f18\u96c5\u7684\u89e3\u51b3\u65b9\u6848\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4f18\u96c5\u6253\u9020\u6316\u7f3a\u53e3\u6548\u679c\uff1amask \u7684\u5de7\u5999\u5e94\u7528<\/strong><\/p>\n<p>\u5982\u4f55\u7528 CSS \u521b\u5efa\u5e26\u6709\u7f3a\u53e3\u7684\u5143\u7d20\uff0c\u4e00\u76f4\u662f\u4e00\u4e2a\u4ee4\u4eba\u56f0\u6270\u7684\u95ee\u9898\u3002\u5e38\u89c1\u7684\u89e3\u51b3\u65b9\u6cd5\u662f\u4f7f\u7528 mask \u906e\u7f69\uff0c\u4f46\u8fd9\u79cd\u65b9\u6cd5\u9700\u8981\u4e3a\u6bcf\u4e2a\u7f3a\u53e3\u521b\u5efa\u5355\u72ec\u7684\u906e\u7f69\u5c42\uff0c\u65e2\u7e41\u7410\u53c8\u6d6a\u8d39\u8d44\u6e90\u3002<\/p>\n<p>\u662f\u5426\u5b58\u5728\u66f4\u4f18\u96c5\u7684\u89e3\u51b3\u529e\u6cd5\u5462\uff1f\u7b54\u6848\u5c31\u5728\u4e8e mask \u4e2d\u9c9c\u4e3a\u4eba\u77e5\u7684\u5c5e\u6027\u2014\u2014mask-composite\u3002<\/p>\n<p><strong>mask-composite \u7684\u5965\u5999<\/strong><\/p>\n<p>mask-composite \u5c5e\u6027\u5141\u8bb8\u60a8\u6307\u5b9a\u906e\u7f69\u7684\u5408\u6210\u65b9\u5f0f\u3002\u901a\u8fc7\u4f7f\u7528 &#8220;xor&#8221; \u503c\uff0c\u60a8\u53ef\u4ee5\u5c06\u906e\u7f69\u5143\u7d20\u6709\u50cf\u7d20\u7684\u5730\u65b9\u8bbe\u7f6e\u4e3a\u4e0d\u663e\u793a\uff0c\u800c\u5c06\u906e\u7f69\u5143\u7d20\u4e2d\u6ca1\u6709\u50cf\u7d20\u7684\u5730\u65b9\u8bbe\u7f6e\u4e3a\u663e\u793a\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p><strong>\u5de7\u7528\u6e10\u53d8\u80cc\u666f\u548c SVG \u56fe\u7247<\/strong><\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u5229\u7528 mask-composite \u7684\u7279\u6027\uff0c\u901a\u8fc7\u4f7f\u7528\u7eaf\u8272\u6e10\u53d8\u80cc\u666f\u51cf\u53bb\u53f3\u4fa7\u7684\u51f9\u89d2\u5f62\u72b6\u6765\u5b9e\u73b0\u6316\u7f3a\u53e3\u6548\u679c\u3002\u8fd9\u4e2a\u51f9\u89d2\u53ef\u4ee5\u5de7\u5999\u5730\u4f7f\u7528 SVG \u56fe\u7247\u6765\u5236\u4f5c\u3002<\/p>\n<p><strong>\u5177\u4f53\u64cd\u4f5c\u6b65\u9aa4<\/strong><\/p>\n<pre>-webkit-mask: url('\u51f9\u89d2.svg'), linear-gradient(red,red);\n-webkit-mask-composite: xor; \/*\u53ea\u663e\u793a\u4e0d\u91cd\u5408\u7684\u5730\u65b9*\/\n-webkit-mask-position: right 30px, 0 0;\n-webkit-mask-repeat: no-repeat, repeat;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u793a\u4f8b\u6f14\u793a<\/strong><\/p>\n<p>\u901a\u8fc7\u6539\u53d8\u51f9\u89d2 SVG \u56fe\u7247\u7684\u4f4d\u7f6e\uff0c\u6211\u4eec\u53ef\u4ee5\u63a7\u5236\u7f3a\u53e3\u5728\u53f3\u4fa7\u7684\u4e0a\u4e0b\u4f4d\u7f6e\uff0c\u5b9e\u73b0\u52a8\u6001\u7684\u6548\u679c\u3002<\/p>\n<p><strong>\u7ed3\u8bed<\/strong><\/p>\n<p>\u867d\u7136\u672c\u6587\u4fa7\u91cd\u4e8e\u4f7f\u7528 mask-composite \u7684\u5de7\u7528\uff0c\u4f46\u5b83\u53cd\u6620\u4e86 CSS \u4e2d\u7075\u6d3b\u6027\u548c\u521b\u9020\u529b\u7684\u65e0\u9650\u53ef\u80fd\u6027\u3002\u901a\u8fc7\u6df1\u5165\u4e86\u89e3\u8fd9\u4e9b\u9c9c\u4e3a\u4eba\u77e5\u7684\u5c5e\u6027\u548c\u7279\u6027\uff0c\u6211\u4eec\u53ef\u4ee5\u7a81\u7834\u9650\u5236\uff0c\u4e3a\u8bbe\u8ba1\u548c\u4ea4\u4e92\u5e26\u6765\u66f4\u591a\u65b0\u9896\u548c\u4ee4\u4eba\u5174\u594b\u7684\u6548\u679c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fCSS \u6316\u7f3a\u53e3\u6548\u679c\uff1amask-composite \u5c5e\u6027\u5982\u4f55\u5b9e\u73b0\u4f18\u96c5\u7684\u89e3\u51b3\u65b9\u6848\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>\u4f18\u96c5\u6253\u9020\u6316\u7f3a\u53e3\u6548\u679c\uff1amask \u7684\u5de7\u5999\u5e94\u7528 \u5982\u4f55\u7528 CSS \u521b\u5efa\u5e26\u6709\u7f3a\u53e3\u7684\u5143\u7d20\uff0c\u4e00\u76f4\u662f\u4e00\u4e2a\u4ee4\u4eba\u56f0\u6270\u7684\u95ee\u9898\u3002\u5e38\u89c1\u7684\u89e3\u51b3\u65b9\u6cd5\u662f\u4f7f\u7528 mask \u906e\u7f69\uff0c\u4f46\u8fd9\u79cd\u65b9\u6cd5\u9700\u8981\u4e3a\u6bcf\u4e2a\u7f3a\u53e3\u521b\u5efa\u5355\u72ec\u7684\u906e\u7f69\u5c42\uff0c\u65e2\u7e41\u7410\u53c8\u6d6a\u8d39\u8d44\u6e90\u3002 \u662f\u5426\u5b58\u5728\u66f4\u4f18\u96c5\u7684\u89e3\u51b3\u529e\u6cd5\u5462\uff1f\u7b54\u6848\u5c31\u5728\u4e8e mask \u4e2d\u9c9c\u4e3a\u4eba\u77e5\u7684\u5c5e\u6027\u2014\u2014mask-composite\u3002 mask-composite \u7684\u5965\u5999 mask-composite \u5c5e\u6027\u5141\u8bb8\u60a8\u6307\u5b9a\u906e\u7f69\u7684\u5408\u6210\u65b9\u5f0f\u3002\u901a\u8fc7\u4f7f\u7528 &#8220;xor&#8221; \u503c\uff0c\u60a8\u53ef\u4ee5\u5c06\u906e\u7f69\u5143\u7d20\u6709\u50cf\u7d20\u7684\u5730\u65b9\u8bbe\u7f6e\u4e3a\u4e0d\u663e\u793a\uff0c\u800c\u5c06\u906e\u7f69\u5143\u7d20\u4e2d\u6ca1\u6709\u50cf\u7d20\u7684\u5730\u65b9\u8bbe\u7f6e\u4e3a\u663e\u793a\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u5de7\u7528\u6e10\u53d8\u80cc\u666f\u548c SVG \u56fe\u7247 \u6211\u4eec\u53ef\u4ee5\u5229\u7528 mask-composite \u7684\u7279\u6027\uff0c\u901a\u8fc7\u4f7f\u7528\u7eaf\u8272\u6e10\u53d8\u80cc\u666f\u51cf\u53bb\u53f3\u4fa7\u7684\u51f9\u89d2\u5f62\u72b6\u6765\u5b9e\u73b0\u6316\u7f3a\u53e3\u6548\u679c\u3002\u8fd9\u4e2a\u51f9\u89d2\u53ef\u4ee5\u5de7\u5999\u5730\u4f7f\u7528 SVG \u56fe\u7247\u6765\u5236\u4f5c\u3002 \u5177\u4f53\u64cd\u4f5c\u6b65\u9aa4 -webkit-mask: url(&#8216;\u51f9\u89d2.svg&#8217;), linear-gradient(red,red); -webkit-mask-composite: xor; \/*\u53ea\u663e\u793a\u4e0d\u91cd\u5408\u7684\u5730\u65b9*\/ -webkit-mask-position: right 30px, 0 0; -webkit-mask-repeat: no-repeat, repeat; \u767b\u5f55\u540e\u590d\u5236 \u793a\u4f8b\u6f14\u793a \u901a\u8fc7\u6539\u53d8\u51f9\u89d2 SVG \u56fe\u7247\u7684\u4f4d\u7f6e\uff0c\u6211\u4eec\u53ef\u4ee5\u63a7\u5236\u7f3a\u53e3\u5728\u53f3\u4fa7\u7684\u4e0a\u4e0b\u4f4d\u7f6e\uff0c\u5b9e\u73b0\u52a8\u6001\u7684\u6548\u679c\u3002 \u7ed3\u8bed \u867d\u7136\u672c\u6587\u4fa7\u91cd\u4e8e\u4f7f\u7528 mask-composite \u7684\u5de7\u7528\uff0c\u4f46\u5b83\u53cd\u6620\u4e86 CSS \u4e2d\u7075\u6d3b\u6027\u548c\u521b\u9020\u529b\u7684\u65e0\u9650\u53ef\u80fd\u6027\u3002\u901a\u8fc7\u6df1\u5165\u4e86\u89e3\u8fd9\u4e9b\u9c9c\u4e3a\u4eba\u77e5\u7684\u5c5e\u6027\u548c\u7279\u6027\uff0c\u6211\u4eec\u53ef\u4ee5\u7a81\u7834\u9650\u5236\uff0c\u4e3a\u8bbe\u8ba1\u548c\u4ea4\u4e92\u5e26\u6765\u66f4\u591a\u65b0\u9896\u548c\u4ee4\u4eba\u5174\u594b\u7684\u6548\u679c\u3002 \u4ee5\u4e0a\u5c31\u662fCSS \u6316\u7f3a\u53e3\u6548\u679c\uff1amask-composite \u5c5e\u6027\u5982\u4f55\u5b9e\u73b0\u4f18\u96c5\u7684\u89e3\u51b3\u65b9\u6848\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-27443","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27443","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=27443"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27443\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}