{"id":26874,"date":"2024-11-24T11:45:45","date_gmt":"2024-11-24T03:45:45","guid":{"rendered":"https:\/\/fwq.ai\/blog\/26874\/"},"modified":"2024-11-24T11:45:45","modified_gmt":"2024-11-24T03:45:45","slug":"%e5%a6%82%e4%bd%95%e7%94%a8css%e5%92%8csvg%e5%ae%9e%e7%8e%b0%e9%80%8f%e6%98%8e%e8%83%8c%e6%99%af%e5%85%ad%e8%be%b9%e5%bd%a2%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/26874\/","title":{"rendered":"\u5982\u4f55\u7528CSS\u548cSVG\u5b9e\u73b0\u900f\u660e\u80cc\u666f\u516d\u8fb9\u5f62\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173111865050229.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u7528CSS\u548cSVG\u5b9e\u73b0\u900f\u660e\u80cc\u666f\u516d\u8fb9\u5f62\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u7528CSS\u548cSVG\u5b9e\u73b0\u900f\u660e\u80cc\u666f\u516d\u8fb9\u5f62\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5b9e\u73b0\u900f\u660e\u80cc\u666f\u516d\u8fb9\u5f62<\/strong><\/p>\n<p>\u9700\u6c42\uff1a\u5b9e\u73b0\u4e00\u4e2a\u516d\u8fb9\u5f62\uff0c\u80cc\u666f\u8272\u9700\u4e3a\u900f\u660e\uff0cborder\u4e3a1px\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5b9e\u73b0\u900f\u660e\u80cc\u666f\u7684\u516d\u8fb9\u5f62\u3002<\/p>\n<p><strong>SVG<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u5229\u7528SVG\u7684 \u5143\u7d20\uff0c\u8bbe\u7f6efill\u4e3a\u900f\u660e\u8272\uff0cstroke\u4e3a\u6307\u5b9a\u989c\u8272\uff0c\u53ef\u4ee5\u521b\u5efa\u516d\u8fb9\u5f62\uff1a <\/p>\n<pre>&lt;svg width=\"500\" height=\"500\"&gt;\n  &lt;polygon points=\"100,30 140,50 140,90 100,110 60,90 60,50\" style=\"fill: transparent;stroke: #e07cc2; stroke-width:3px;\"&gt;&lt;\/polygon&gt;\n&lt;\/svg&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>CSS<\/strong><\/p>\n<p>\u4f7f\u7528CSS\u7684clip-path\u5c5e\u6027\uff0c\u53ef\u4ee5\u526a\u88c1\u5143\u7d20\u5f62\u6210\u516d\u8fb9\u5f62\uff0c\u540c\u65f6\u8bbe\u7f6e\u80cc\u666f\u8272\u4e3a\u900f\u660e\uff1a<\/p>\n<pre>&lt;div class=\"hexagon-container\"&gt;\n  &lt;div class=\"hexagon\"&gt;&lt;\/div&gt;\n&lt;\/div&gt;\n\n&lt;style&gt;\n  .hexagon-container {\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    height: 200px;\n  }\n\n  .hexagon {\n    position: relative;\n    width: 100px;\n    height: 100px;\n    background-color: pink;\n    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);\n  }\n\n  .hexagon:before {\n    content: \"\";\n    position: absolute;\n    top: 2px;\n    left: 2px;\n    width: 96px;\n    height: 96px;\n    background-color: #fff;\n    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);\n  }\n&lt;\/style&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u7528CSS\u548cSVG\u5b9e\u73b0\u900f\u660e\u80cc\u666f\u516d\u8fb9\u5f62\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>\u5b9e\u73b0\u900f\u660e\u80cc\u666f\u516d\u8fb9\u5f62 \u9700\u6c42\uff1a\u5b9e\u73b0\u4e00\u4e2a\u516d\u8fb9\u5f62\uff0c\u80cc\u666f\u8272\u9700\u4e3a\u900f\u660e\uff0cborder\u4e3a1px\u3002 \u89e3\u51b3\u65b9\u6848 \u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5b9e\u73b0\u900f\u660e\u80cc\u666f\u7684\u516d\u8fb9\u5f62\u3002 SVG \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u5229\u7528SVG\u7684 \u5143\u7d20\uff0c\u8bbe\u7f6efill\u4e3a\u900f\u660e\u8272\uff0cstroke\u4e3a\u6307\u5b9a\u989c\u8272\uff0c\u53ef\u4ee5\u521b\u5efa\u516d\u8fb9\u5f62\uff1a &lt;svg width=&#8221;500&#8243; height=&#8221;500&#8243;&gt; &lt;polygon points=&#8221;100,30 140,50 140,90 100,110 60,90 60,50&#8243; style=&#8221;fill: transparent;stroke: #e07cc2; stroke-width:3px;&#8221;&gt;&lt;\/polygon&gt; &lt;\/svg&gt; \u767b\u5f55\u540e\u590d\u5236 CSS \u4f7f\u7528CSS\u7684clip-path\u5c5e\u6027\uff0c\u53ef\u4ee5\u526a\u88c1\u5143\u7d20\u5f62\u6210\u516d\u8fb9\u5f62\uff0c\u540c\u65f6\u8bbe\u7f6e\u80cc\u666f\u8272\u4e3a\u900f\u660e\uff1a &lt;div class=&#8221;hexagon-container&#8221;&gt; &lt;div class=&#8221;hexagon&#8221;&gt;&lt;\/div&gt; &lt;\/div&gt; &lt;style&gt; .hexagon-container { display: flex; justify-content: center; align-items: center; height: 200px; } .hexagon { position: relative; width: 100px; height: 100px; background-color: pink; clip-path: polygon(50% [&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-26874","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26874","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=26874"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26874\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=26874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=26874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=26874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}