{"id":2134,"date":"2024-11-10T10:48:44","date_gmt":"2024-11-10T02:48:44","guid":{"rendered":"https:\/\/fwq.ai\/blog\/2134\/"},"modified":"2024-11-10T10:48:44","modified_gmt":"2024-11-10T02:48:44","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-css-mask-composite-%e4%bc%98%e9%9b%85%e5%9c%b0%e5%88%9b%e5%bb%ba%e6%8c%96%e7%bc%ba%e5%8f%a3%e6%95%88%e6%9e%9c%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/2134\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 CSS mask-composite \u4f18\u96c5\u5730\u521b\u5efa\u6316\u7f3a\u53e3\u6548\u679c\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173064510457716.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 CSS mask-composite \u4f18\u96c5\u5730\u521b\u5efa\u6316\u7f3a\u53e3\u6548\u679c\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 CSS mask-composite \u4f18\u96c5\u5730\u521b\u5efa\u6316\u7f3a\u53e3\u6548\u679c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4f18\u96c5\u5730\u8bbe\u7f6e  \u6316\u7f3a\u53e3<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 css \u65f6\uff0c\u5982\u679c\u60a8\u5e0c\u671b\u521b\u5efa\u4e00\u4e2a\u5e26\u6709\u7f3a\u53e3\u7684\u5143\u7d20\uff0c\u901a\u5e38\u4f1a\u8003\u8651\u4f7f\u7528\u906e\u7f69 (mask) \u529f\u80fd\u3002\u7136\u800c\uff0c\u4f20\u7edf\u7684\u906e\u7f69\u529f\u80fd\u53ea\u80fd\u663e\u793a\u5177\u6709\u50cf\u7d20\u7684\u533a\u57df\u3002\u5982\u679c\u60a8\u5e0c\u671b\u663e\u793a\u7f3a\u5c11\u50cf\u7d20\u7684\u533a\u57df\uff0c\u5219\u53ef\u80fd\u9700\u8981\u4e3a\u6bcf\u4e2a\u6b65\u9aa4\u521b\u5efa\u4e00\u4e2a\u5355\u72ec\u7684\u906e\u7f69\u5c42\u56fe\u7247\uff0c\u8fd9\u76f8\u5f53\u9ebb\u70e6\u3002<\/p>\n<p><strong>\u5de7\u7528 mask-composite<\/strong><\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 mask \u4e2d\u7684 mask-composite \u5c5e\u6027\u3002\u8be5\u5c5e\u6027\u63a7\u5236\u5982\u4f55\u5c06\u906e\u7f69\u4e0e\u80cc\u540e\u7684\u5185\u5bb9\u5408\u6210\u3002\u901a\u8fc7\u5c06 mask-composite \u8bbe\u7f6e\u4e3a xor\uff08\u5f02\u6216\uff09\uff0c\u6211\u4eec\u53ef\u4ee5\u53ea\u663e\u793a\u906e\u7f69\u548c\u80cc\u540e\u7684\u5185\u5bb9\u4e2d\u4e0d\u91cd\u5408\u7684\u90e8\u5206\u3002<\/p>\n<p><strong>\u793a\u4f8b\u4ee3\u7801<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u4ee5\u4e0b\u4ee3\u7801\u793a\u4f8b\u6f14\u793a\u4e86\u5982\u4f55\u4f7f\u7528 mask-composite \u521b\u5efa\u4e00\u4e2a\u6316\u7f3a\u53e3\uff1a<\/p>\n<pre>-webkit-mask: url('\u51f9\u89d2.svg'), linear-gradient(red,red);\n-webkit-mask-composite: xor;\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>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86\u7eaf\u8272\u6e10\u53d8\u80cc\u666f\u51cf\u53bb\u53f3\u4fa7\u7684\u51f9\u89d2 svg \u56fe\u7247\u3002\u901a\u8fc7\u6539\u53d8 -webkit-mask-position \u7684\u503c\uff0c\u6211\u4eec\u53ef\u4ee5\u63a7\u5236\u51f9\u89d2\u5728\u53f3\u4fa7\u79fb\u52a8\u7684\u4f4d\u7f6e\u3002<\/p>\n<p><strong>\u5b9e\u9645\u5e94\u7528<\/strong><\/p>\n<p>\u60a8\u53ef\u4ee5\u901a\u8fc7\u81ea\u5b9a\u4e49\u5c5e\u6027\u6765\u63a7\u5236\u7bad\u5934\u7684\u4e0a\u4e0b\u4f4d\u7f6e\uff0c\u5177\u4f53\u5b9e\u73b0\u53ef\u4ee5\u5728 codepen \u793a\u4f8b\u4e2d\u627e\u5230\u3002\u6b64\u5916\uff0c\u5728\u4f5c\u8005\u4e4b\u524d\u7684\u6587\u7ae0\u300acss mask \u5b9e\u73b0\u9f20\u6807\u8ddf\u968f\u9542\u7a7a\u6548\u679c\u300b\u4e2d\u4e5f\u4ecb\u7ecd\u4e86\u7c7b\u4f3c\u7684\u6280\u672f\u3002<\/p>\n<p>\u901a\u8fc7\u4f7f\u7528 mask-composite \u5c5e\u6027\uff0c\u6211\u4eec\u53ef\u4ee5\u66f4\u4f18\u96c5\u5730\u521b\u5efa\u6316\u7f3a\u53e3\u6548\u679c\uff0c\u800c\u65e0\u9700\u4e3a\u6bcf\u4e2a\u6b65\u9aa4\u521b\u5efa\u5355\u72ec\u7684\u906e\u7f69\u5c42\u56fe\u7247\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 CSS mask-composite \u4f18\u96c5\u5730\u521b\u5efa\u6316\u7f3a\u53e3\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>\u4f18\u96c5\u5730\u8bbe\u7f6e \u6316\u7f3a\u53e3 \u5728\u4f7f\u7528 css \u65f6\uff0c\u5982\u679c\u60a8\u5e0c\u671b\u521b\u5efa\u4e00\u4e2a\u5e26\u6709\u7f3a\u53e3\u7684\u5143\u7d20\uff0c\u901a\u5e38\u4f1a\u8003\u8651\u4f7f\u7528\u906e\u7f69 (mask) \u529f\u80fd\u3002\u7136\u800c\uff0c\u4f20\u7edf\u7684\u906e\u7f69\u529f\u80fd\u53ea\u80fd\u663e\u793a\u5177\u6709\u50cf\u7d20\u7684\u533a\u57df\u3002\u5982\u679c\u60a8\u5e0c\u671b\u663e\u793a\u7f3a\u5c11\u50cf\u7d20\u7684\u533a\u57df\uff0c\u5219\u53ef\u80fd\u9700\u8981\u4e3a\u6bcf\u4e2a\u6b65\u9aa4\u521b\u5efa\u4e00\u4e2a\u5355\u72ec\u7684\u906e\u7f69\u5c42\u56fe\u7247\uff0c\u8fd9\u76f8\u5f53\u9ebb\u70e6\u3002 \u5de7\u7528 mask-composite \u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 mask \u4e2d\u7684 mask-composite \u5c5e\u6027\u3002\u8be5\u5c5e\u6027\u63a7\u5236\u5982\u4f55\u5c06\u906e\u7f69\u4e0e\u80cc\u540e\u7684\u5185\u5bb9\u5408\u6210\u3002\u901a\u8fc7\u5c06 mask-composite \u8bbe\u7f6e\u4e3a xor\uff08\u5f02\u6216\uff09\uff0c\u6211\u4eec\u53ef\u4ee5\u53ea\u663e\u793a\u906e\u7f69\u548c\u80cc\u540e\u7684\u5185\u5bb9\u4e2d\u4e0d\u91cd\u5408\u7684\u90e8\u5206\u3002 \u793a\u4f8b\u4ee3\u7801 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4ee5\u4e0b\u4ee3\u7801\u793a\u4f8b\u6f14\u793a\u4e86\u5982\u4f55\u4f7f\u7528 mask-composite \u521b\u5efa\u4e00\u4e2a\u6316\u7f3a\u53e3\uff1a -webkit-mask: url(&#8216;\u51f9\u89d2.svg&#8217;), linear-gradient(red,red); -webkit-mask-composite: xor; -webkit-mask-position: right 30px, 0 0; -webkit-mask-repeat: no-repeat, repeat; \u767b\u5f55\u540e\u590d\u5236 \u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86\u7eaf\u8272\u6e10\u53d8\u80cc\u666f\u51cf\u53bb\u53f3\u4fa7\u7684\u51f9\u89d2 svg \u56fe\u7247\u3002\u901a\u8fc7\u6539\u53d8 -webkit-mask-position \u7684\u503c\uff0c\u6211\u4eec\u53ef\u4ee5\u63a7\u5236\u51f9\u89d2\u5728\u53f3\u4fa7\u79fb\u52a8\u7684\u4f4d\u7f6e\u3002 \u5b9e\u9645\u5e94\u7528 \u60a8\u53ef\u4ee5\u901a\u8fc7\u81ea\u5b9a\u4e49\u5c5e\u6027\u6765\u63a7\u5236\u7bad\u5934\u7684\u4e0a\u4e0b\u4f4d\u7f6e\uff0c\u5177\u4f53\u5b9e\u73b0\u53ef\u4ee5\u5728 codepen \u793a\u4f8b\u4e2d\u627e\u5230\u3002\u6b64\u5916\uff0c\u5728\u4f5c\u8005\u4e4b\u524d\u7684\u6587\u7ae0\u300acss mask \u5b9e\u73b0\u9f20\u6807\u8ddf\u968f\u9542\u7a7a\u6548\u679c\u300b\u4e2d\u4e5f\u4ecb\u7ecd\u4e86\u7c7b\u4f3c\u7684\u6280\u672f\u3002 \u901a\u8fc7\u4f7f\u7528 mask-composite \u5c5e\u6027\uff0c\u6211\u4eec\u53ef\u4ee5\u66f4\u4f18\u96c5\u5730\u521b\u5efa\u6316\u7f3a\u53e3\u6548\u679c\uff0c\u800c\u65e0\u9700\u4e3a\u6bcf\u4e2a\u6b65\u9aa4\u521b\u5efa\u5355\u72ec\u7684\u906e\u7f69\u5c42\u56fe\u7247\u3002 \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 CSS mask-composite \u4f18\u96c5\u5730\u521b\u5efa\u6316\u7f3a\u53e3\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-2134","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2134","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=2134"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2134\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=2134"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=2134"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=2134"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}