{"id":27036,"date":"2024-11-24T08:10:19","date_gmt":"2024-11-24T00:10:19","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27036\/"},"modified":"2024-11-24T08:10:19","modified_gmt":"2024-11-24T00:10:19","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8css%e5%88%9b%e5%bb%ba%e8%be%b9%e6%a1%86%e4%b8%ba1px%e3%80%81%e8%83%8c%e6%99%af%e9%80%8f%e6%98%8e%e7%9a%84%e5%85%ad%e8%be%b9%e5%bd%a2%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27036\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528CSS\u521b\u5efa\u8fb9\u6846\u4e3a1px\u3001\u80cc\u666f\u900f\u660e\u7684\u516d\u8fb9\u5f62\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173114984742416.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528CSS\u521b\u5efa\u8fb9\u6846\u4e3a1px\u3001\u80cc\u666f\u900f\u660e\u7684\u516d\u8fb9\u5f62\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528CSS\u521b\u5efa\u8fb9\u6846\u4e3a1px\u3001\u80cc\u666f\u900f\u660e\u7684\u516d\u8fb9\u5f62\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5728\u4e2d\u521b\u5efa\u8fb9\u6846\u4e3a1px\u3001\u80cc\u666f\u900f\u660e\u7684\u516d\u8fb9\u5f62<\/strong><\/p>\n<p>\u4e3a\u4e86\u5b9e\u73b0\u516d\u8fb9\u5f62\u5e76\u4f7f\u5176\u80cc\u666f\u900f\u660e\uff0c\u6709\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\uff1a\u4f7f\u7528SVG\u6216CSS\uff1a<\/p>\n<p><strong>\u4f7f\u7528SVG<\/strong><\/p>\n<p>SVG\u662f\u4e00\u79cd\u57fa\u4e8e\u77e2\u91cf\u7684\u56fe\u50cf\u683c\u5f0f\u3002\u5b83\u662f\u4e00\u79cd\u521b\u5efa\u590d\u6742\u5f62\u72b6\u7684\u7406\u60f3\u9009\u62e9\uff0c\u5305\u62ec\u516d\u8fb9\u5f62\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u4f7f\u7528SVG\u521b\u5efa\u516d\u8fb9\u5f62\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n    &lt;head&gt;\n        &lt;meta charset=\"utf-8\"&gt;\n        &lt;title&gt;SVG&lt;\/title&gt;\n        &lt;link rel=\"styleSheet\" type=\"text\/css\" href=\".\/style.css\"&gt;\n    &lt;\/head&gt;\n    &lt;body&gt;\n        &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;\n    &lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4f7f\u7528CSS<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>CSS\u7684clip-path\u5c5e\u6027\u53ef\u4ee5\u7528\u6765\u521b\u5efa\u516d\u8fb9\u5f62\u3002\u53ef\u4ee5\u914d\u5408background-color\u548cborder\u5c5e\u6027\u6765\u521b\u5efa\u8fb9\u6846\u4e3a1px\u3001\u80cc\u666f\u900f\u660e\u7684\u516d\u8fb9\u5f62\u3002\u5982\u4e0b\u4ee3\u7801\u6240\u793a\uff1a<\/p>\n<pre>&lt;!DOCTYPE html&gt;\n&lt;head&gt;\n&lt;style&gt;\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;\n&lt;\/head&gt;\n&lt;body&gt;\n\n&lt;div class=\"hexagon\"&gt;&lt;\/div&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528CSS\u521b\u5efa\u8fb9\u6846\u4e3a1px\u3001\u80cc\u666f\u900f\u660e\u7684\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>\u5728\u4e2d\u521b\u5efa\u8fb9\u6846\u4e3a1px\u3001\u80cc\u666f\u900f\u660e\u7684\u516d\u8fb9\u5f62 \u4e3a\u4e86\u5b9e\u73b0\u516d\u8fb9\u5f62\u5e76\u4f7f\u5176\u80cc\u666f\u900f\u660e\uff0c\u6709\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\uff1a\u4f7f\u7528SVG\u6216CSS\uff1a \u4f7f\u7528SVG SVG\u662f\u4e00\u79cd\u57fa\u4e8e\u77e2\u91cf\u7684\u56fe\u50cf\u683c\u5f0f\u3002\u5b83\u662f\u4e00\u79cd\u521b\u5efa\u590d\u6742\u5f62\u72b6\u7684\u7406\u60f3\u9009\u62e9\uff0c\u5305\u62ec\u516d\u8fb9\u5f62\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u4f7f\u7528SVG\u521b\u5efa\u516d\u8fb9\u5f62\u7684\u793a\u4f8b\u4ee3\u7801\uff1a &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset=&#8221;utf-8&#8243;&gt; &lt;title&gt;SVG&lt;\/title&gt; &lt;link rel=&#8221;styleSheet&#8221; type=&#8221;text\/css&#8221; href=&#8221;.\/style.css&#8221;&gt; &lt;\/head&gt; &lt;body&gt; &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; &lt;\/body&gt; &lt;\/html&gt; \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528CSS \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b CSS\u7684clip-path\u5c5e\u6027\u53ef\u4ee5\u7528\u6765\u521b\u5efa\u516d\u8fb9\u5f62\u3002\u53ef\u4ee5\u914d\u5408background-color\u548cborder\u5c5e\u6027\u6765\u521b\u5efa\u8fb9\u6846\u4e3a1px\u3001\u80cc\u666f\u900f\u660e\u7684\u516d\u8fb9\u5f62\u3002\u5982\u4e0b\u4ee3\u7801\u6240\u793a\uff1a &lt;!DOCTYPE html&gt; &lt;head&gt; &lt;style&gt; .hexagon { position: relative; width: 100px; height: 100px; background-color: pink; clip-path: polygon(50% 0%, [&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-27036","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27036","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=27036"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27036\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27036"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27036"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27036"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}