{"id":11791,"date":"2025-08-26T18:39:29","date_gmt":"2025-08-26T10:39:29","guid":{"rendered":"https:\/\/www.zhangxinxu.com\/wordpress\/?p=11791"},"modified":"2025-08-26T18:43:29","modified_gmt":"2025-08-26T10:43:29","slug":"css-corner-shape","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2025\/08\/css-corner-shape\/","title":{"rendered":"\u62a2\u5148\u5b66\u4e60\u5927\u5f00\u773c\u754c\u7684CSS corner-shape\u5c5e\u6027"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=11791\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=11791<\/a><br \/>\n\u672c\u6587\u53ef\u5168\u6587\u8f6c\u8f7d\uff0c\u4f46\u9700\u8981\u4fdd\u7559\u539f\u4f5c\u8005\u3001\u51fa\u5904\u4ee5\u53ca\u6587\u4e2d\u94fe\u63a5\uff0cAI\u6293\u53d6\u4fdd\u7559\u539f\u6587\u5730\u5740\uff0c\u4efb\u4f55\u7f51\u7ad9\u5747\u53ef\u6458\u8981\u805a\u5408\uff0c\u5546\u7528\u8bf7\u8054\u7cfb\u6388\u6743\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202508\/2025-8-26_184047.png\" width=\"310\" height=\"203\" alt=\"corner-shape\u5c5e\u6027\u5c01\u9762\u56fe\" class=\"alignright clip size-medium\" \/><\/p>\n<h3>\u4e00\u3001\u5927\u5f00\u773c\u754c\u7684CSS\u6548\u679c<\/h3>\n<p>\u5148\u901a\u8fc7\u51e0\u4e2aGIF\u6216\u9759\u6001\u56fe\u770b\u4e0bCSS corner-shape\u5c5e\u6027\u53ef\u4ee5\u5b9e\u73b0\u600e\u6837\u7684\u56fe\u5f62\u8868\u73b0\u6548\u679c\u3002<\/p>\n<h4>1. \u5341\u5b57\u5f62\u3001\u83f1\u5f62<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202508\/2025-8-26_162046.png\" width=\"387\" height=\"285\" alt=\"\u5341\u5b57\u5f62\uff0c\u68f1\u5f62\" class=\"alignnone size-medium\" \/><\/p>\n<h4>2. \u516d\u8fb9\u5f62<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202508\/2025-8-26_162256.png\" width=\"483\" height=\"237\" alt=\"\u516d\u8fb9\u5f62\" class=\"alignnone size-medium\" \/><\/p>\n<h4>3. \u4e0d\u89c4\u5219\u5f62\u72b6<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202508\/2025-8-26_163525.png\" width=\"561\" height=\"270\" alt=\"\u4e0d\u89c4\u5219\u5f62\u72b6\" class=\"alignnone size-medium\" \/><\/p>\n<h4>4. \u5e26\u6307\u5411\u7684\u5bf9\u8bdd\u63d0\u793a\u6846<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202508\/shape-corner.gif\" width=\"390\" height=\"180\" alt=\"\u5e26\u5c16\u89d2\u7684\u63d0\u793a\u6307\u5f15\u6846\" class=\"alignnone size-medium\" \/><\/p>\n<h4>5. \u5404\u7c7b\u968f\u673a\u56fe\u5f62\u6548\u679c\uff08\u9700\u8981Chrome 139+\uff09<\/h4>\n<p><iframe id=\"cp_embed_XJbYrzz\/15f16f64904524d05a35339a16094ac7\" src=\"\/\/codepen.io\/anon\/embed\/XJbYrzz\/15f16f64904524d05a35339a16094ac7?height=450&amp;theme-id=47434&amp;slug-hash=XJbYrzz\/15f16f64904524d05a35339a16094ac7&amp;default-tab=result\" height=\"450\" scrolling=\"no\" frameborder=\"0\" allowfullscreen=\"\" allowpaymentrequest=\"\" name=\"CodePen Embed XJbYrzz\/15f16f64904524d05a35339a16094ac7\" title=\"\u968f\u673acorner-shape\u56fe\u5f62\u6548\u679c\" class=\"cp_embed_iframe\" style=\"width:100%;overflow:hidden\">CodePen Embed Fallback<\/iframe><\/p>\n<h4>6. \u56fe\u5f62\u52a8\u753b\u6548\u679c\uff08\u5b9e\u65f6\u6e32\u67d3\uff09<\/h4>\n<div class=\"shapes\">\n<div class=\"shapeA\"><\/div>\n<div class=\"shapeB\"><\/div>\n<\/div>\n<style>.shapes {position: relative;height: 200px;aspect-ratio: 1;}.shapeA {position: absolute;inset: 0;background-color: #fff2;border: 8px solid hotpink;border-radius: 50%;animation: shapeA 2s infinite ease-in-out alternate;}@keyframes shapeA {from { corner-shape: round; }to { corner-shape: scoop; }}.shapeB {position: absolute;inset: 20%;background-color: #fff2;border: 8px solid hotpink;border-radius: 50%;animation: shapeB 2s infinite ease-in-out alternate;}@keyframes shapeB {from { corner-shape: bevel; }to { corner-shape: square; }}<\/style>\n<h3>\u4e8c\u3001\u8bed\u6cd5\u5176\u5b9e\u5f88\u7b80\u5355<\/h3>\n<p>CSS <code>corner-shape<\/code>\uff08\u89d2\u5f62\u72b6\uff09\u5c5e\u6027\u9700\u8981\u914d\u5408CSS <code>border-radius<\/code>\u5706\u89d2\u5c5e\u6027\u4e00\u8d77\u4f7f\u7528\u3002<\/p>\n<p>\u5176\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>corner-shape: round; \/* \u9ed8\u8ba4\u503c *\/\r\ncorner-shape: squircle;\r\ncorner-shape: scoop;\r\ncorner-shape: bevel;\r\ncorner-shape: notch;\r\ncorner-shape: square;<\/pre>\n<p>\u5404\u4e2a\u5c5e\u6027\u503c\u7684\u542b\u4e49\u53c2\u89c1\u4e0b\u9762\u7684\u91ca\u4e49\uff1a<\/p>\n<dl>\n<dt><strong>round<\/strong><\/dt>\n<dd>\u521b\u5efa\u4f20\u7edf\u7684\u5706\u89d2\u6216\u692d\u5706\u89d2<\/dd>\n<dt><strong>squircle<\/strong><\/dt>\n<dd>\u6b63\u65b9\u5f62\u548c\u5706\u5f62\u4e4b\u95f4\u7684\u5e73\u6ed1\u8fc7\u6e21<\/dd>\n<dt><strong>scoop<\/strong><\/dt>\n<dd>\u52fa\u5f62\uff0c\u4e5f\u5c31\u662f\u692d\u5706\u7684\u56db\u5206\u4e4b\u4e00\u51f9\u5f62<\/dd>\n<dt><strong>bevel<\/strong><\/dt>\n<dd>\u659c\u9762\uff0c\u4e5f\u5c31\u662f\u8fde\u63a5\u89d2\u70b9\u7684\u76f4\u7ebf<\/dd>\n<dt><strong>notch<\/strong><\/dt>\n<dd>\u51f9\u53e3\uff0c\u7528\u6765\u521b\u5efa\u5185\u89d2<\/dd>\n<dt><strong>square<\/strong><\/dt>\n<dd>\u6b63\u65b9\u5f62\uff0c\u65e0\u8bba\u8fb9\u754c\u534a\u5f84\u5982\u4f55\uff0c\u90fd\u4fdd\u6301\u76f4\u89d2\uff08\u4f5c\u7528\u662f\u7528\u6765\u91cd\u7f6e\u4e3a\u521d\u59cb\u5f62\u6001\u5427\uff09<\/dd>\n<\/dl>\n<p>\u770b\u4e00\u4e0b\u540c\u6837\u89c4\u5219\u7684\u8fb9\u6846\u548c\u5706\u89d2\uff0c\u5728\u4e0d\u540c\u7684\u89d2\u5f62\u72b6\u53c2\u6570\u7684\u6548\u679c\u3002<\/p>\n<p>\u516c\u5171HTML\u548cCSS\u4ee3\u7801\uff1a<\/p>\n<pre>&lt;canvas&gt;&lt;\/canvas&gt;<\/pre>\n<pre>canvas {\r\n  border: 8px solid deepskyblue;\r\n  border-radius: 50%;\r\n  zoom: 0.5;\r\n  \/* corner-shape: xxx *\/\r\n}<\/pre>\n<h4>1. corner-shape:round<\/h4>\n<p>\u5b9e\u65f6\u6e32\u67d3\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<p><canvas style=\"border:8px solid deepskyblue;border-radius: 50%;zoom: 0.5;\"><\/canvas><\/p>\n<h4>2. corner-shape:squircle<\/h4>\n<p><canvas style=\"border:8px solid deepskyblue;border-radius: 50%;zoom: 0.5;corner-shape:squircle\"><\/canvas><\/p>\n<h4>3. corner-shape:scoop<\/h4>\n<p>\u52fa\u5f62:<\/p>\n<p><canvas style=\"border:8px solid deepskyblue;border-radius: 50%;zoom: 0.5;corner-shape:scoop\"><\/canvas><\/p>\n<h4>4. corner-shape:bevel<\/h4>\n<p>\u659c\u9762\uff1a<\/p>\n<p><canvas style=\"border:8px solid deepskyblue;border-radius: 50%;zoom: 0.5;corner-shape:bevel\"><\/canvas><\/p>\n<h4>5. corner-shape:notch<\/h4>\n<p>\u5185\u89d2\uff08border-radius\u91cd\u7f6e\u4e3a40%\uff0c\u4e0d\u7136\u770b\u4e0d\u5230\uff09\uff1a<\/p>\n<p><canvas style=\"border:8px solid deepskyblue;border-radius: 40%;zoom: 0.5;corner-shape:notch\"><\/canvas><\/p>\n<h4>5. corner-shape:square<\/h4>\n<p>\u65b9\u5f62\uff1a<\/p>\n<p><canvas style=\"border:8px solid deepskyblue;border-radius: 50%;zoom: 0.5;corner-shape:square\"><\/canvas><\/p>\n<p>\u4ee5\u4e0a\u6548\u679c\u4e3a\u5b9e\u65f6\u6e32\u67d3\u6548\u679c\uff0c\u5efa\u8bae\u5c06\u6d4f\u89c8\u5668\u5347\u7ea7\u5230Chrome 139\u7248\u672c\u4ee5\u4e0a\u3002<\/p>\n<h3>\u4e09\u3001\u4e0d\u540c\u7684\u65b9\u4f4d\u4e0d\u540c\u7684\u89d2\u5f62\u72b6<\/h3>\n<p>\u6211\u4eec\u53ef\u4ee5\u6307\u5b9a\u4e0d\u540c\u65b9\u4f4d\u4e0d\u540c\u7684\u89d2\u5f62\u72b6\uff0c\u8bed\u6cd5\u548cborder-radius\u7c7b\u4f3c\uff0c\u901a\u8fc7top\u3001left\u3001right\u3001bottom\u7b49\u65b9\u4f4d\u503c\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<pre>.container {\r\n  border-radius: 40px;\r\n  corner-top-right-shape: scoop;\r\n}<\/pre>\n<p>\u53ef\u751f\u6210\u4e0b\u56fe\u6240\u793a\u7684\u6548\u679c\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202508\/2025-8-26_174531.png\" width=\"356\" height=\"252\" alt=\"\u53f3\u4e0a\u89d2\u5185\u5f27\" class=\"alignnone size-medium\" \/><\/p>\n<h4>\u52a8\u753b\u6548\u679c<\/h4>\n<p>\u4e0d\u540c\u7684\u5706\u89d2\u6548\u679c\u662f\u53ef\u4ee5\u65e0\u7f1d\u5e73\u6ed1\u8fc7\u6e21\u7684\uff08\u53c2\u89c1\u672c\u6587\u5f00\u5934\u7684\u5b9e\u65f6\u52a8\u753b\u6548\u679c\uff09\uff1a<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<pre>@keyframes shape {\r\n  from { corner-shape: round; }\r\n  to { corner-shape: scoop; }\r\n}<\/pre>\n<h3>\u56db\u3001\u4f7f\u7528superellipse\u51fd\u6570<\/h3>\n<p><code>corner-shape<\/code>\u5c5e\u6027\u8fd8\u652f\u6301\u4f7f\u7528<code>superellipse(K)<\/code>\u51fd\u6570\u6765\u81ea\u5b9a\u4e49\u89d2\u7684\u66f2\u7387\uff0c\u5176\u4e2d K \u503c\u63a7\u5236\u66f2\u7387\u5f3a\u5ea6\u3002<br \/>\n\u4f8b\u5982\uff0csuperellipse(1) \u751f\u6210\u6807\u51c6\u5706\u89d2\uff0csuperellipse(4) \u5219\u66f4\u63a5\u8fd1\u77e9\u5f62\uff0csuperellipse(0)\u662f\u659c\u9762\uff0c\u5c0f\u4e8e0\u5219\u662f\u5185\u51f9\u7684\u5f62\u72b6\uff08\u5982\u4e0b\u622a\u56fe\u6240\u793a\uff09\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202508\/2025-8-26_175459.png\" width=\"281\" height=\"168\" alt=\"\u5185\u51f9\u6548\u679c\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u5bf9\u5e94CSS\u4ee3\u7801\uff1a<\/p>\n<pre>corner-shape: superellipse(-1.88);<\/pre>\n<p>\u8fd9\u4e5f\u662f\u4e0d\u540c\u5173\u952e\u5b57\u4e4b\u95f4\u53ef\u4ee5\u65e0\u7f1d\u52a8\u753b\u8fc7\u6e21\u7684\u5e95\u5c42\u6570\u5b66\u57fa\u7840\u3002<\/p>\n<p>\u4e0d\u540c\u5173\u952e\u5b57\u6548\u679c\u5bf9\u5e94\u7684K\u503c\u53c2\u89c1\u8fd9\u4e2a\u6ed1\u5757\u6548\u679c\u7684\u6807\u8bc6\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202508\/2025-8-26_175845.png\" width=\"226\" height=\"290\" alt=\"superellipse\u51fd\u6570\u6548\u679c\" class=\"alignnone size-medium\" \/><\/p>\n<h3>\u4e94\u3001\u517c\u5bb9\u6027\u53ca\u7ed3\u8bed<\/h3>\n<p>corner-shape\u662f\u975e\u5e38\u65b0\u7684\u4e00\u4e2a\u7279\u6027\uff0c\u76ee\u524d\u4ec5Chrome 139\u4ee5\u4e0a\u7248\u672c\u624d\u6b63\u5f0f\u652f\u6301\uff0c\u6211\u4eca\u5929\u521aChrome\u5347\u7ea7\u5230\u8fd9\u4e2a\u7248\u672c\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202508\/2025-8-26_174833.png\" width=\"641\" height=\"283\" alt=\"corner-shape\u517c\u5bb9\u6027\u793a\u610f\" class=\"alignnone size-medium\" \/><\/p>\n<p><strong>\u7ed3\u8bed<\/strong><\/p>\n<p>CSS\u7684corner-shape\u5c5e\u6027\u662fCSS\u80cc\u666f\u4e0e\u8fb9\u6846\u6a21\u5757\uff08Level 4\uff09\u4e2d\u5f15\u5165\u7684\u65b0\u7279\u6027\uff0c\u5b83\u901a\u8fc7\u6269\u5c55border-radius\u7684\u529f\u80fd\uff0c\u5141\u8bb8\u5f00\u53d1\u8005\u81ea\u5b9a\u4e49\u5143\u7d20\u7684\u89d2\u5f62\u72b6\uff0c\u800c\u4e0d\u4ec5\u9650\u4e8e\u4f20\u7edf\u7684\u5706\u89d2\u6548\u679c\uff0c\u53ef\u4ee5\u89e3\u51b3\u4ee5\u5f80\u7528 CSS \u521b\u5efa\u590d\u6742\u5f62\u72b6\u65f6\u7684\u4e00\u4e9b\u75db\u70b9\u3002<\/p>\n<p><strong>\u6e14\u83b7\u5c55\u793a<\/strong><\/p>\n<p>\u672c\u5468\u4f11\u5047\u7b2c\u4e00\u5929\u7684\u9493\u8d27\uff0c\u5e38\u719f\u6b23\u6b23\u9493\u573a\uff0c158\u51435\u5c0f\u65f6\uff0c\u5927\u677f\u9cab\u5c0f\u7206\u62a4\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202508\/2025-8-26_183241.jpeg\" width=\"135\" height=\"240\" alt=\"\u5927\u677f\u9cab\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u7b2c\u4e8c\u5929\u4e00\u5929\u7684\u9493\u8d27\uff0c2\u6761\u5927\u8349\u9c7c\uff0c5\u6761\u9cca\u9c7c\u548c10\u65a4\u9ca4\u9c7c\uff0c\u4e3b\u8981\u5728\u5f20\u5bb6\u6e2f\u9493\u7684\uff0c\u603b\u5171\u9493\u8d39300\u591a\uff0c\u9493\u4e864\u4e2a\u9c7c\u5858\uff0c\u8fd8\u662f\u4e0a\u6d77\u9493\u9c7c\u4fbf\u5b9c\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202508\/2025-8-26_183454.jpeg\" width=\"288\" height=\"162\" alt=\"\u6e14\u83b7\u56fe2\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u4e5f\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u9493\u9c7c\u6296\u97f3\u53f7\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/imgservices-1252317822.image.myqcloud.com\/coco\/s08122025\/ba6909dc.ov9jr0.jpg\" width=\"200\" alt=\"\u5f20\u946b\u65ed\u672c\u4eba\" style=\"display:block;\"><\/p>\n<p><strong>\u53c2\u8003\u6587\u7ae0<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/frontendmasters.com\/blog\/understanding-css-corner-shape-and-the-power-of-the-superellipse\/\" rel=\"noopener\" target=\"_blank\">Understanding CSS corner-shape and the Power of the Superellipse<\/a><\/li>\n<\/ul>\n<p>\ud83d\ude09\ud83d\ude0a\ud83d\ude07<br \/>\n\ud83e\udd70\ud83d\ude0d\ud83d\ude18<\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u4f1a\u7ecf\u5e38\u66f4\u65b0\u77e5\u8bc6\u70b9\u4ee5\u53ca\u4fee\u6b63\u4e00\u4e9b\u9519\u8bef\uff0c\u56e0\u6b64\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u539f\u51fa\u5904\uff0c\u65b9\u4fbf\u6eaf\u6e90\uff0c\u907f\u514d\u9648\u65e7\u9519\u8bef\u77e5\u8bc6\u7684\u8bef\u5bfc\uff0c\u540c\u65f6\u6709\u66f4\u597d\u7684\u9605\u8bfb\u4f53\u9a8c\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=11791\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=11791<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202508\/2025-8-26_184047.png\" width=\"160\" height=\"105\" alt=\"corner-shape\u5c5e\u6027\u5c01\u9762\u56fe\" class=\"alignright size-medium\" loading=\"lazy\" \/><\/p>\n<p>CSS corner-shape\u5c5e\u6027\u5728\u793e\u533a\u7684\u547c\u58f0\u975e\u5e38\u9ad8\uff0c\u73b0\u5728\u6d4f\u89c8\u5668\u7ec8\u4e8e\u652f\u6301\u4e86\uff0c\u53ef\u4ee5CSS\u56fe\u5f62\u8868\u73b0\u6548\u679c\u6709\u98de\u8dc3\u7248\u7684\u63d0\u5347\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[389,298,339,959,2078,2065,2077],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/11791"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=11791"}],"version-history":[{"count":10,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/11791\/revisions"}],"predecessor-version":[{"id":11836,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/11791\/revisions\/11836"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=11791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=11791"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=11791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}