{"id":6516,"date":"2017-11-07T00:17:28","date_gmt":"2017-11-06T16:17:28","guid":{"rendered":"http:\/\/www.zhangxinxu.com\/wordpress\/?p=6516"},"modified":"2018-11-15T17:07:14","modified_gmt":"2018-11-15T09:07:14","slug":"pure-css-colorful-circle","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2017\/11\/pure-css-colorful-circle\/","title":{"rendered":"3\u79cd\u7eafCSS\u5b9e\u73b0\u4e2d\u95f4\u9542\u7a7a\u768412\u8272\u5f69\u8679\u6e10\u53d8\u5706\u73af\u65b9\u6cd5"},"content":{"rendered":"<p>by <a href=\"http:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=6516\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=6516<\/a><br \/>\n\u672c\u6587\u53ef\u5168\u6587\u8f6c\u8f7d\uff0c\u4f46\u9700\u5f97\u5230\u539f\u4f5c\u8005\u4e66\u9762\u8bb8\u53ef\uff0c\u540c\u65f6\u4fdd\u7559\u539f\u4f5c\u8005\u548c\u51fa\u5904\uff0c\u6458\u8981\u5f15\u6d41\u5219\u968f\u610f\u3002<\/p>\n<h3>\u4e00\u3001\u4eceSVG\u5b9e\u73b0\u591a\u5f69\u5706\u73af\u5012\u8ba1\u65f6\u6548\u679c\u8bf4\u8d77<\/h3>\n<p>\u4e0a\u5468\u6211<a href=\"http:\/\/www.zhangxinxu.com\/study\/201710\/colorful-time-count-down-svg-circle.html\" rel=\"noopener\" target=\"_blank\">\u505a\u4e86\u4e2ademo<\/a>\uff0c\u4f7f\u7528SVG\u548c<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=4089\">stroke-dasharray\u548cstroke-dashoffset\u7279\u6027<\/a>\u5b9e\u73b0\u4e86\u4e00\u4e2a\u5f69\u6761\u5706\u73af\u5012\u8ba1\u65f6\u6548\u679c\uff0c\u5927\u6982\u957f\u4e0b\u9762\u8fd9\u6837\u5b50\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-02_221910.png\" width=\"300\" height=\"295\" alt=\"\u5f69\u6761\u5706\u73af\" class=\"alignnone\"><\/p>\n<p>\u539f\u7406\u662f\u4f7f\u7528\u4e24\u4e2a\u6e10\u53d8\u534a\u5706\u65e0\u7f1d\u53e0\u52a0\u5728\u4e00\u8d77\u3002<\/p>\n<p>\u4f7f\u7528SVG\u5b9e\u73b0\u7684\u4f18\u70b9\u662f\u517c\u5bb9\u6027\u975e\u5e38\u597d\uff0cIE9\u6d4f\u89c8\u5668\u4e5f\u662f\u652f\u6301\u7684\u3002<\/p>\n<p>\u4e0d\u8db3\u5728\u4e8e\u5b66\u4e60\u6210\u672c\u6bd4\u8f83\u9ad8\uff0c\u76f8\u5173\u7684SVG\u4ee3\u7801\u8981\u60f3\u5b8c\u6574\u7684\u624b\u5199\u51fa\u6765\uff0c\u8fd8\u662f\u9700\u8981\u4e0d\u5c11\u79ef\u7d2f\u7684\u3002<\/p>\n<p>\u4e8e\u662f\u6211\u5c31\u7422\u78e8\u6709\u6ca1\u6709\u66f4\u7b80\u5355\u7684\u65b9\u6cd5\u5b9e\u73b0\u7c7b\u4f3c\u7684\u591a\u5f69\u5706\u73af\u6e10\u53d8\u6548\u679c\uff0c\u6700\u597d\u7eafCSS\u5c31\u80fd\u641e\u5b9a\u3002<\/p>\n<p>\u7ede\u5c3d\u8111\u6c41\u60f3\u51fa\u4e86\u4e0b\u9762\u4e09\u79cd\u5b9e\u73b0\u65b9\u6cd5\uff0c\u4e3a\u4e86\u5c3d\u53ef\u80fd\u9a8c\u8bc1\u65b9\u6cd5\u7684\u53ef\u884c\u6027\uff0c\u6211\u628a\u5706\u73af\u7684\u6e10\u53d8\u989c\u8272\u4ece3\u8272\u53d8\u6210\u4e8612\u8272\u3002<\/p>\n<p>\u4e0b\u9762\u4f9d\u6b21\u4ecb\u7ecd\u8fd9\u4e09\u79cd\u65b9\u6cd5\u3002<\/p>\n<h3>\u4e8c\u3001\u501f\u52a9CSS3 conic-gradient\u9525\u5f62\u6e10\u53d8\u5b9e\u73b012\u8272\u6e10\u53d8\u5706\u73af<\/h3>\n<p>\u73af\u5f62\u5e26\u4e0a\u7684\u6e10\u53d8\u6548\u679c\uff0c\u672c\u8d28\u4e0a\u5c31\u662f\u4e00\u79cd\u9525\u5f62\u6e10\u53d8\uff0c\u56e0\u6b64\uff0c\u6211\u4eec\u76f4\u63a5\u4f7f\u7528\uff0cCSS3 <code>conic-gradient<\/code>\u9525\u5f62\u6e10\u53d8\u5b9e\u73b0\u5e94\u8be5\u662f\u6700\u7b80\u5355\u6700\u76f4\u63a5\u7684\u65b9\u6cd5\u3002<\/p>\n<p>\u5982\u4e0bHTML\u548cCSS\uff1a<\/p>\n<pre>&lt;div class=\"circle\"&gt;&lt;\/div&gt;<\/pre>\n<pre>.circle {\n    width: 300px; height: 300px;\n    background: conic-gradient(#9ED110, #50B517, #179067, #476EAF, #9f49ac, #CC42A2, #FF3BA7, #FF5800, #FF8100, #FEAC00, #FFCC00, #EDE604);\n    border-radius: 50%;\n}<\/pre>\n<p>\u6b64\u65f6\u7684\u6548\u679c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-08_221600.jpg\" width=\"363\" height=\"362\" alt=\"12\u8272\u9525\u5f62\u6e10\u53d8\u6548\u679c\u622a\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u4f46\u662f\u6211\u4eec\u9700\u8981\u7684\u6548\u679c\u4e0d\u662f\u5706\u997c\uff0c\u800c\u662f\u4e00\u4e2a\u5706\u73af\uff0c\u4e5f\u5c31\u662f\u4e2d\u95f4\u533a\u57df\u9700\u8981\u9542\u7a7a\u3002<\/p>\n<p>\u6709\u4e00\u79cd\u6bd4\u8f83\u5de7\u5999\u7684\u505a\u6cd5\uff0c\u5c31\u662f\u641e\u4e00\u4e2a\u8ddf\u80cc\u666f\u8272\u4e00\u6837\u534a\u5f84\u5c0f\u4e00\u70b9\u7684\u5706\u5f62\u997c\u8986\u76d6\u5728\u4e2d\u95f4\uff0c\u8fd9\u6837\u89c6\u89c9\u770b\u4e0a\u53bb\u5c31\u662f\u4e00\u4e2a\u5706\u73af\uff0c\u8fd9\u4e5f\u662f\u4e0d\u4e00\u4e2a\u4e0d\u9519\u7684\u65b9\u6cd5\u3002\u4f46\u662f\u5982\u679c\u6211\u4eec\u7684\u80cc\u666f\u662f\u4e00\u4e2a\u590d\u6742\u7684\u56fe\u6848\uff0c\u6b64\u65f6\uff0c\u8fd9\u79cd\u65b9\u6cd5\u6050\u6015\u5c31\u4e0d\u80fd\u9002\u7528\u3002<\/p>\n<p>\u4f60\u600e\u4e48\u9700\u8981\u627e\u5230\u4e00\u79cd\u4e2d\u95f4\u533a\u57df\u662f\u771f\u5b9e\u9542\u7a7a\u7684\u65b9\u6cd5\uff0c\u600e\u4e48\u5904\u7406\u5462\uff1f<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u501f\u52a9CSS3\u906e\u7f69<code>mask<\/code>\u5c5e\u6027\u6765\u5b9e\u73b0\uff0cCSS3 <code>mask<\/code>\u906e\u7f69\u9664\u4e86\u652f\u6301PNG\u56fe\u7247\uff0cSVG\u56fe\u5f62\uff0c\u5176\u8fd8\u652f\u6301CSS3\u6e10\u53d8\u80cc\u666f\u56fe\u3002\u4e8e\u662f\uff0c\u6211\u4eec\u53ea\u9700\u8981\u4f7f\u7528CSS3\u5f84\u5411\u6e10\u53d8<code>radial-gradient<\/code>\u8bed\u6cd5\u751f\u6210\u4e00\u4e2a\u4e2d\u95f4\u900f\u660e\uff0c\u8fb9\u7f18\u5b9e\u8272\u7684\u5706\u73af\u5373\u53ef\u3002<\/p>\n<p>\u4e8e\u662f\u6709\uff08\u8fd9\u91cc\u7701\u7565\u4e86<code>mask<\/code>\u5c5e\u6027\u7684<code>webkit<\/code>\u79c1\u6709\u524d\u7f00\uff09\uff1a<\/p>\n<pre>.circle {\n    width: 300px; height: 300px;\n    background: conic-gradient(#9ED110, #50B517, #179067, #476EAF, #9f49ac, #CC42A2, #FF3BA7, #FF5800, #FF8100, #FEAC00, #FFCC00, #EDE604);\n    border-radius: 50%;\n    <span style=\"color:#cd0000;\">mask: radial-gradient(transparent 110px, #000 110px);<\/span>\n}<\/pre>\n<p>\u4e8e\u662f\u6211\u4eec\u768412\u8272\u5706\u73af\u6e10\u53d8\u6548\u679c\u5c31\u5b9e\u73b0\u4e86\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-08_222606.png\" width=\"381\" height=\"360\" alt=\"\u9525\u5f62\u6e10\u53d8\u4e0b\u768412\u8272\u5f69\u8679\u5706\u73af\u6548\u679c\" class=\"alignnone\" \/><\/p>\n<p>\u518d\u914d\u5408JS\u8bbe\u7f6e<code>clip-path<\/code>\u526a\u88c1\u6211\u4eec\u7684\u56fe\u5f62\uff0c\u5c31\u53ef\u4ee5\u5b9e\u73b012\u8272\u7684\u5f69\u8679\u5706\u73af\u5012\u8ba1\u65f6\u6548\u679c\u4e86\u3002<\/p>\n<p>\u773c\u89c1\u4e3a\u5b9e\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/study\/201711\/colorful-circle-by-css-conic-gradient.html\" rel=\"noopener\" target=\"_blank\">\u501f\u52a9CSS3 mask\u906e\u7f69\u548cconic-gradient\u5b9e\u73b0\u7684\u591a\u5f69\u5706\u73afdemo<\/a><\/p>\n<p><strong>\u4f18\u70b9\u548c\u4e0d\u8db3<\/strong><br \/>\n\u8fd9\u4e2a\u65b9\u6cd5\u770b\u4e0a\u53bb\u5f88\u7b80\u5355\uff0c\u5f88\u5b8c\u7f8e\uff0c\u4f46\u662f\u5374\u6709\u4e2a\u81f4\u547d\u7684\u7f3a\u9677\uff0c\u90a3\u5c31\u662f\u517c\u5bb9\u6027\u95ee\u9898\uff01<\/p>\n<p>CSS3\u9525\u5f62\u6e10\u53d8<code>conic-gradient<\/code>\u76ee\u524d\u4ec5Chrome\u6d4f\u89c8\u5668\u624d\u652f\u6301\uff0c\u5e76\u4e14Chrome\u6d4f\u89c8\u5668\u8fd8\u662f\u9700\u8981\u5f00\u542f\u5b9e\u9a8c\u529f\u80fd\u9009\u9879\u624d\u80fd\u652f\u6301\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-08_224837.png\" width=\"519\" height=\"334\" alt=\"\u9525\u5f62\u6e10\u53d8\u7cdf\u7cd5\u7684\u517c\u5bb9\u6027\u95ee\u9898\" class=\"alignnone\" \/><\/p>\n<p>\u56e0\u6b64\u5f53\u4e0b\u6b64\u65b9\u6cd5\u57fa\u672c\u4e0a\u6ca1\u6709\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u5e94\u7528\u7684\u53ef\u80fd\u6027\uff0c\u9700\u8981\u770b\u770b\u6709\u6ca1\u6709\u4ec0\u4e48\u5176\u4ed6\u89e3\u51b3\u65b9\u6848\uff1f<\/p>\n<h3>\u4e09\u3001\u501f\u52a9CSS3 linear-gradient\u7ebf\u6027\u6e10\u53d8\u8fd1\u4f3c\u5b9e\u73b012\u8272\u6e10\u53d8\u5706\u73af<\/h3>\n<p>\u867d\u7136\u9525\u5f62\u6e10\u53d8\u6d4f\u89c8\u5668\u7684\u517c\u5bb9\u6027\u4e0d\u600e\u4e48\u6837\uff0c\u4f46\u662f\u7ebf\u6027\u6e10\u53d8\u5b83\u517c\u5bb9\u6027\u5f88\u597d\u554a\uff0c\u662f\u4e0d\u662f\u53ef\u4ee5\u674e\u4ee3\u6843\u50f5\u5462\uff1f<\/p>\n<p>\u548c\u4e00\u5f00\u59cbSVG\u5706\u73af\u539f\u7406\u7c7b\u4f3c\uff1a<br \/>\n\u628a\u6211\u4eec\u7684\u5706\u73af\u5206\u6210\u5de6\u534a\u90e8\u5206\u548c\u53f3\u534a\u90e8\u5206\uff0c\u5de6\u534a\u90e8\u5206\u662f\u4e00\u5957\u7ebf\u6027\u6e10\u53d8\uff0c\u53f3\u534a\u90e8\u5206\u662f\u53e6\u5916\u4e00\u5957\u7ebf\u6027\u6e10\u53d8\uff0c\u7136\u540e\u6700\u5e95\u90e8\u7684\u7ebf\u6027\u6e10\u53d8\u989c\u8272\u662f\u4e00\u6837\u7684\uff0c\u7406\u8bba\u4e0a\u5728\u89c6\u89c9\u4e0a\u770b\u8d77\u6765\u5c31\u80fd\u591f\u5f62\u6210\u4e00\u4e2a\u5b8c\u7f8e\u7684\u73af\u3002<\/p>\n<p>\u5982\u4e0bHTML\u548cCSS\u4ee3\u7801\uff1a<\/p>\n<pre>&lt;div class=\"circle\"&gt;\n    &lt;div class=\"circle-left\"&gt;&lt;\/div&gt;\n    &lt;div class=\"circle-right\"&gt;&lt;\/div&gt;\n&lt;\/div&gt;<\/pre>\n<pre>.circle {\n    width: 300px; height: 300px;\n    border-radius: 50%;\n    mask: radial-gradient(transparent 110px, #000 110px);\n    overflow: hidden;\n}\n.circle-left {\n    width: 50%; height: 100%;\n    background: linear-gradient(to bottom, #EDE604, #FFCC00, #FEAC00, #FF8100, #FF5800, #FF3BA7, #CC42A2);\n    float: left;\n}\n.circle-right {\n    width: 50%; height: 100%;\n    float: right;\n    background: linear-gradient(to bottom, #9ED110, #50B517, #179067, #476EAF, #9f49ac, #CC42A2);\n}<\/pre>\n<p>\u7136\u800c\u6700\u540e\u7684\u6548\u679c\u5374\u662f\u4e0b\u9762\u8fd9\u6837\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-08_230302.png\" width=\"394\" height=\"359\" alt=\"\u4e24\u4e2a\u6e10\u53d8\u65e0\u7f1d\u8fde\u63a5\u5931\u8d25\u793a\u610f\" class=\"alignnone\" \/><\/p>\n<p>\u54a6\uff0c\u5947\u602a\uff0c\u540c\u6837\u7684\u5b9e\u73b0\u539f\u7406\uff0c\u4e3a\u4ec0\u4e48\u4e00\u5f00\u59cb\u7684SVG\u5b9e\u73b0\u6ca1\u6709\u8fd9\u6837\u7684\u73b0\u8c61\u5462\uff1f<\/p>\n<p>\u5b9e\u9645\u4e0a\uff0cSVG\u7684\u5b9e\u73b0\u5e95\u90e8\u7684\u8fde\u63a5\u4e5f\u662f\u4e0d\u5b8c\u7f8e\u7684\uff0c\u4f46\u662f\u7531\u4e8e\u6211\u4eec\u4e0a\u9762\u7684\u8fd9\u4e2a\u5706\u73af\u6e10\u53d8\u989c\u8272\u6bd4\u8f83\u5c11\uff0c\u540c\u65f6\u989c\u8272\u6bd4\u8f83\u63a5\u8fd1\uff0c\u56e0\u6b64\u4e0d\u4ed4\u7ec6\u770b\uff0c\u6839\u672c\u770b\u4e0d\u51fa\u6765\uff0c\u8fde\u63a5\u6709\u95ee\u9898\u7684\u3002<\/p>\n<p>\u4f46\u662f\u8fd9\u91cc\u768412\u8272\u6e10\u53d8\u5c31\u4e0d\u4e00\u6837\u4e86\uff0c\u6e10\u53d8\u989c\u8272\u8de8\u5ea6\u660e\u663e\u533a\u5206\u5927\uff0c\u56e0\u6b64\u5f88\u660e\u663e\u770b\u51fa\u6765\u63a5\u7f1d\u6709\u95ee\u9898\uff0c\u90a3\u6709\u6ca1\u6709\u4ec0\u4e48\u529e\u6cd5\u53ef\u4ee5\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u5462\uff1f<\/p>\n<p>\u6709\uff01\u6211\u60f3\u7684\u529e\u6cd5\u662f\uff0c\u5c31\u662f\u5728\u4e0b\u9762\u63a5\u7f1d\u4e0d\u5b8c\u7f8e\u7684\u5730\u65b9\u6253\u4e00\u4e2a\u5c0f\u8865\u4e01\uff0c\u5c31\u50cf\u662f\u6211\u56fd\u6865\u6881\u5efa\u9020\u63a5\u7f1d\u5904\u91cd\u65b0\u6d47\u7b51\u4e00\u6837\uff0c\u4e8e\u662fHTML\u53d8\u6210\u4e0b\u9762\u8fd9\u6837\uff0c\u589e\u52a0\u4e00\u4e2a<code>.circle-bottom<\/code>\uff1a<\/p>\n<pre>&lt;div class=\"circle\"&gt;\n    &lt;div class=\"circle-left\"&gt;&lt;\/div&gt;\n    &lt;div class=\"circle-right\"&gt;&lt;\/div&gt;\n    <span style=\"color:#cd0000;\">&lt;div class=\"circle-bottom\"&gt;&lt;\/div&gt;<\/span>\n&lt;\/div&gt;<\/pre>\n<p>\u5bf9\u5e94\u7684CSS\u5982\u4e0b\uff1a<\/p>\n<pre>.circle-bottom {\n    position: absolute; \n    height: 40px; width: 30px;\n    bottom: 3px; left: 0; right: 0;\n    margin: auto;\n    <span style=\"color:green;\">\/* \u4e0b\u9762\u4e24\u4e2a\u58f0\u660e\u662f\u8865\u4e01\u5173\u952e *\/<\/span>\n    background: linear-gradient(to right, #DB3FA3, #C443A3);\n    filter: blur(5px);\n}<\/pre>\n<p>\u4e5f\u5c31\u662f\u63a5\u7f1d\u5904\u641e\u4e00\u4e2a\u5c0f\u5c0f\u7684\u6c34\u5e73\u6e10\u53d8\uff0c\u540c\u65f6\u9002\u5f53\u9ad8\u65af\u6a21\u7cca\uff0c\u6de1\u5316\u8fb9\u754c\u3002\u7136\u540e\u8089\u773c\u6240\u89c1\u7684\u6548\u679c\u5c31\u53d8\u6210\u4e0b\u9762\u8fd9\u6837\uff0c\u51e0\u4e4e\u770b\u4e0d\u51fa\u4efb\u4f55\u5f02\u5e38\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-08_231109.png\" width=\"356\" height=\"361\" alt=\"\u63a5\u7f1d\u5904\u6253\u5b8c\u8865\u4e01\u4e4b\u540e\u7684\u5706\u73af\u6548\u679c\" class=\"alignnone\" \/><\/p>\n<p>\u63a5\u4e0b\u6765\u5c31\u7b80\u5355\u4e86\uff0c\u540c\u6837\u5730\uff0cJS\u8bbe\u7f6e\u5706\u73af<code>clip-path<\/code>\u52a8\u6001\u526a\u88c1\uff0c\u5b9e\u73b0\u6211\u4eec\u60f3\u8981\u7684\u5012\u8ba1\u65f6\u6548\u679c\u3002<\/p>\n<p>\u773c\u89c1\u4e3a\u5b9e\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u7684\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/study\/201711\/colorful-circle-by-css-linear-gradient.html\" rel=\"noopener\" target=\"_blank\">linear-gradient\u7ebf\u6027\u6e10\u53d8\u5b9e\u73b0\u7684\u591a\u5f69\u5706\u73afdemo<\/a><\/p>\n<p><strong>\u4f18\u70b9\u548c\u4e0d\u8db3<\/strong><br \/>\n\u6b64\u65b9\u6cd5\u7684\u4f18\u70b9\u5728\u4e8e\u517c\u5bb9\u6027\u8db3\u591f\uff08\u4ec5IE\u4e0d\u652f\u6301\uff09\uff0c\u5728\u79fb\u52a8\u7aef\u53ef\u4ee5\u65e0\u969c\u788d\u4f7f\u7528\u3002<\/p>\n<p>\u4e0d\u8db3\u5728\u4e8e\u8fd9\u4e2a\u5706\u73af\u7684\u6e10\u53d8\u5e76\u4e0d\u662f\u5f84\u5411\u53d1\u6563\u7684\uff0c\u800c\u662f\u81ea\u4e0a\u800c\u4e0b\u7684\uff0c\u548c\u771f\u6b63\u610f\u4e49\u4e0a\u7684\u5706\u73af\u6e10\u53d8\u8fd8\u662f\u6709\u4e9b\u5dee\u5f02\u7684\u3002<\/p>\n<p>\u90a3\u6709\u6ca1\u6709\u4ec0\u4e48\u65b9\u6cd5\uff0c\u65e2\u4fdd\u8bc1\u517c\u5bb9\u6027\uff0c\u540c\u65f6\u6e10\u53d8\u53c8\u662f\u771f\u6b63\u610f\u4e49\u4e0a\u7684\u73af\u5f62\u6e10\u53d8\u5462\uff1f<\/p>\n<h3>\u56db\u3001\u501f\u52a9CSS clip\u526a\u88c1\u3001transform\u65cb\u8f6c\u548c\u6a21\u7cca\u6ee4\u955c\u5b9e\u73b012\u8272\u6e10\u53d8\u5706\u73af<\/h3>\n<p>\u6b64\u65b9\u6cd5\u9700\u8981\u4e00\u5b9a\u7684\u7406\u89e3\u6210\u672c\uff0c\u8bf7\u5bb9\u6211\u6162\u6162\u9053\u6765\u3002<\/p>\n<h4>1. \u5982\u4f55\u5b9e\u73b0\u4e00\u4e2a30\u00b0\u7684\u6247\u5f62\uff1f<\/h4>\n<p>\u5047\u8bbe\u6709\u5982\u4e0bHTML\uff1a<\/p>\n<pre>&lt;div class=\"sector\"&gt;&lt;\/div&gt;<\/pre>\n<p>\u5219\u4e0b\u9762\u7684CSS\u53ef\u751f\u6210\u4e00\u4e2a30\u00b0\u7684\u6247\u5f62\uff1a<\/p>\n<pre>.sector {\n    width: 300px; height: 300px;\n    position: absolute;\n    clip: rect(0 300px 300px 150px);\n    overflow: hidden;\n}\n.sector::after {\n    content: '';\n    width: 100%; height: 100%;\n    background: currentColor;\n    position: absolute;\n    clip: rect(0 150px 300px 0);\n    transform: rotate(30deg);\n    border-radius: 50%;\n}<\/pre>\n<p>\u5b9e\u65f6\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<p><iframe loading=\"lazy\" src=\"\/study\/201711\/sector-30.html\" width=\"320\" height=\"320\" frameborder=0><\/iframe><\/p>\n<p>\u539f\u7406\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u5916\u9762\u5bb9\u5668\u539f\u672c\u662f\u4e2a\u6b63\u65b9\u5f62\uff0c\u4f46\u901a\u8fc7<code>clip<\/code>\u526a\u88c1\u53ea\u663e\u793a\u53f3\u534a\u90e8\u5206\uff1b<\/li>\n<li>\u5b50\u5143\u7d20\u540c\u6837\u5c3a\u5bf8\uff0c\u4f46\u901a\u8fc7<code>clip<\/code>\u526a\u88c1\u53ea\u663e\u793a\u5de6\u534a\u90e8\u5206\u3002\u7136\u540e\u901a\u8fc7\u9002\u5f53\u65cb\u8f6c\u9732\u51fa\u6211\u4eec\u60f3\u8981\u7684\u6247\u5f62\u533a\u57df\uff1b<\/li>\n<\/ol>\n<p>\u539f\u7406\u793a\u610f\u56fe\u5982\u4e0b\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201711\/why-sector.png\" width=\"408\" height=\"420\" alt=\"30\u5ea6\u6247\u5f62\u751f\u6210\u539f\u7406\u793a\u610f\u56fe\" class=\"alignnone\" \/><\/p>\n<h4>2. \u5982\u4f55\u4f7f\u752812\u4e2a30\u00b0\u6247\u5f62\u94fa\u6210\u4e00\u4e2a\u5706<\/h4>\n<p>\u5f88\u7b80\u5355\uff0c\u6211\u4eec\u53ea\u8981\u521b\u65b012\u4e2a\u7c7b\u4f3c\u4e0b\u9762\u7684HTML\uff1a<\/p>\n<pre>&lt;div class=\"sector\"&gt;&lt;\/div&gt;<\/pre>\n<p>\u7136\u540e\u6bcf\u4e2a\u6247\u5f62\u5143\u7d20\u6bd4\u524d\u9762\u4e00\u4e2a\u591a\u9009\u8f6c30\u5ea6\u5c31\u53ef\u4ee5\u4e86\uff0c\u7136\u540e\u6bcf\u4e00\u4e2a\u6247\u5f62\u8bbe\u7f6e\u4e00\u4e2a\u6e10\u53d8\u989c\u8272\uff0cCSS\u7c7b\u4f3c\u4e0b\u9762\uff1a<\/p>\n<pre>.sector:nth-of-type(1) {\n    transform: rotate(0);\n    color: #9ED110;    \n}\n<span style=\"color:green;\">\/* 2-11 \u7565 *\/<\/span>\n.sector:nth-of-type(12) {\n    transform: rotate(330deg);\n    color: #EDE604;    \n}<\/pre>\n<p>\u6211\u4eec\u5c31\u53ef\u4ee5\u5f97\u5230\u7c7b\u4f3c\u4e0b\u56fe\u7684\u6548\u679c\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-08_235547.png\" width=\"360\" height=\"361\" alt=\"12\u8272\u7684\u6e10\u53d8\u5706\u73af\u6548\u679c\" class=\"alignnone\" \/><\/p>\n<h4>3. \u5982\u4f55\u6a21\u7cca\u6247\u5f62\u8272\u5757\u7684\u8fb9\u754c\uff1f<\/h4>\n<p>\u8fd9\u4e2a\u6211\u4eec\u53ef\u4ee5\u501f\u52a9CSS3\u7684<code>filter<\/code>\u6ee4\u955c\u4e2d\u7684\u9ad8\u65af\u6a21\u7cca\u5b9e\u73b0\uff0c\u5047\u8bbe12\u4e2a\u6247\u5f62\u5143\u7d20\u5168\u90e8\u90fd\u5728\u4e00\u4e2a\u7c7b\u540d\u4e3a<code>.sector-group<\/code>\u7684\u5143\u7d20\u4e2d\uff0c\u5219\uff1a<\/p>\n<pre>.sector-group {\n    <span style=\"color:#cd0000;\">filter: blur(15px);<\/span>\n}<\/pre>\n<p>\u6548\u679c\u5982\u4e0b\u56fe\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-08_235939.jpg\" width=\"353\" height=\"363\" alt=\"\u9ad8\u65af\u6a21\u7cca\u540e\u7684\u6548\u679c\" class=\"alignnone\" \/><\/p>\n<p>\u7136\u800c\u9ad8\u65af\u6a21\u7cca\u7684\u8fb9\u7f18\u4f3c\u4e4e\u6709\u4e9b\u95ee\u9898\uff0c\u4e0d\u662f\u5f88\u6e05\u6670\uff0c\u600e\u4e48\u529e\uff1f<\/p>\n<h4>4. \u6a21\u7cca\u7684\u5706\u73af\u8fb9\u7f18\u5982\u4f55\u5904\u7406\uff1f<\/h4>\n<p>\u5176\u5b9e\u5f88\u7b80\u5355\uff0c\u5916\u90e8\u5bb9\u5668\u5c3a\u5bf8\u9650\u5236\uff0c\u91cc\u9762\u6a21\u7cca\u5143\u7d20\u9002\u5f53<code>transform<\/code>\u6bd4\u4f8b\u653e\u5927\u5c31\u53ef\u4ee5\u4e86\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>.circle {\n    width: 300px; height: 300px;\n    border-radius: 50%;\n    position: relative;\n    overflow: hidden;\n}\n.sector-group {\n    filter: blur(15px);\n    <span style=\"color:#cd0000;\">transform: scale(1.2);<\/span>\n}<\/pre>\n<p>\u6b64\u65f6\u6548\u679c\u4e3a\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-09_000333.jpg\" width=\"361\" height=\"355\" alt=\"\u8fb9\u7f18\u8f6e\u5ed3\u6e05\u6670\u7684\u5706\u73af\u56fe\" class=\"alignnone\" \/><\/p>\n<h4>5. \u4f7f\u7528mask\u906e\u7f69\u662f\u663e\u793a\u8fb9\u7f18\u5706\u73af<\/h4>\n<p>CSS\u4ee3\u7801\u793a\u610f\u5982\u4e0b\uff08\u5b9e\u9645\u5f00\u53d1<code>webkit<\/code>\u524d\u7f00\u4e0d\u53ef\u7701\u7565\uff09<\/p>\n<pre>.circle {\n    width: 300px; height: 300px;\n    border-radius: 50%;\n    position: relative;\n    overflow: hidden;\n    <span style=\"color:#cd0000;\">mask: radial-gradient(transparent 110px, #000 110px);<\/span>\n}\n.sector-group {\n    filter: blur(15px);\n    transform: scale(1.2);\n}<\/pre>\n<p>\u6700\u7ec8\uff0c\u6211\u4eec\u768412\u8272\u5f69\u8679\u6e10\u53d8\u5706\u73af\u6548\u679c\u5373\u8fbe\u6210\uff0c\u5982\u4e0bFirefox\u6d4f\u89c8\u5668\u4e0b\u622a\u56fe\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-09_000736.jpg\" width=\"367\" height=\"364\" alt=\"Firefox\u6d4f\u89c8\u5668\u4e0b\u7684\u5f69\u8679\u5706\u73af\u6548\u679c\u622a\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u63a5\u4e0b\u6765\u5c31\u7b80\u5355\u4e86\uff0c\u540c\u6837\u5730\uff0cJS\u8bbe\u7f6e\u5706\u73af<code>clip-path<\/code>\u52a8\u6001\u526a\u88c1\uff0c\u5b9e\u73b0\u6211\u4eec\u60f3\u8981\u7684\u5012\u8ba1\u65f6\u6548\u679c\u3002<\/p>\n<p>\u773c\u89c1\u4e3a\u5b9e\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u7684\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/study\/201711\/colorful-circle-by-css-background-clip-filter-blur.html\" rel=\"noopener\" target=\"_blank\">\u501f\u52a9CSS3 filter\u6a21\u7cca\u548cclip\u5b9e\u73b0\u7684\u591a\u5f69\u5706\u73afdemo<\/a><\/p>\n<p><strong>\u4f18\u70b9\u548c\u4e0d\u8db3<\/strong><br \/>\n\u4f18\u70b9\u5728\u4e8e\u771f\u6b63\u610f\u4e49\u4e0a\u7684\u9525\u5f62\u6e10\u53d8\uff0c\u540c\u65f612\u79cd\u6e10\u53d8\u989c\u8272\u5934\u9996\u5c3e\u5982\u8d2a\u5403\u86c7\u4e00\u6837\uff0c\u5b8c\u5168\u878d\u4e3a\u4e86\u4e00\u4f53\uff0c\u66f4\u6709\u89c6\u89c9\u4f18\u52bf\u3002<\/p>\n<p>\u4e0d\u8db3\u4e4b\u5904\u5728\u4e8eHTML\u548cCSS\u4ee3\u7801\u7a0d\u5fae\u591a\u4e86\u70b9\u3002<\/p>\n<h3>\u56db\u3001\u7ed3\u675f\u8bed<\/h3>\n<p>\u4e25\u683c\u6765\u8bb2\uff0c\u672c\u6587\u4e00\u5171\u4ecb\u7ecd\u4e86\u56db\u79cd\u5f69\u8272\u5706\u73af\u6e10\u53d8\u6548\u679c\u7684\u5b9e\u73b0\uff0c\u53ef\u4ee5\u8bf4\u5404\u6709\u4f18\u7f3a\u70b9\uff0c\u5927\u5bb6\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u9879\u76ee\u60c5\u51b5\uff0c\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u5b9e\u73b0\u3002<\/p>\n<p>\u7136\u800c\u4e00\u4e2a\u4eba\u7684\u79ef\u7d2f\u603b\u662f\u6709\u9650\uff0c\u800c\u521b\u610f\u603b\u662f\u65e0\u9650\u7684\uff0c\u56e0\u6b64\u4e00\u5b9a\u8fd8\u6709\u5176\u4ed6\u66f4\u597d\u66f4\u5999\u66f4\u7b80\u5355\u7684\u5b9e\u73b0\uff0c\u6b22\u8fce\u5206\u4eab\u6b22\u8fce\u6307\u6559\uff01<\/p>\n<p>\u5f53\u7136\u5f69\u8272\u6e10\u53d8\u5706\u73af\u6548\u679c\u4e0d\u4e00\u5b9a\u662f\u7528\u5728\u5012\u8ba1\u65f6\u4e0a\uff0c\u4f8b\u5982\u4e0b\u56fe\u8fd9\u79cdloading\u6548\u679c\uff08\u4e0b\u56fe\u662f\u56fe\u7247\u5b9e\u73b0\u7684\uff09\u5b9e\u9645\u4e0a\u4e5f\u53ef\u4ee5\u5b8c\u5168\u901a\u8fc7CSS\u5b9e\u73b0\u4e86\uff0c\u6bd4\u8f83\u63a8\u8350\u7684\u505a\u6cd5\u662f\u4f7f\u7528\u5de6\u53f3\u534a\u533a\u7684\u7ebf\u6027\u6e10\u53d8\u52a0\u906e\u7f69\uff08\u5728retina\u5c4f\u5e55\u4e0b\u6548\u679c\u771f\u7684\u8d5e\uff09\uff0c\u5177\u4f53\u4ee3\u7801\u5c31\u4e0d\u5c55\u793a\u4e86\uff0c\u5927\u5bb6\u53ef\u4ee5\u81ea\u5df1\u4f5c\u4e3a\u8bfe\u540e\u4f5c\u4e1a\u5b9e\u8df5\u5b9e\u8df5\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201711\/loading_blue.png\" width=\"30\" height=\"30\" alt=\"loading\u6548\u679c\" class=\"spin\" \/><\/p>\n<style>.spin{animation:spin 1s linear infinite;}\n@keyframes spin {\n  from {\n    transform: rotate(0); }\n  to {\n    transform: rotate(-360deg); } }<\/style>\n<p>\u4ee5\u4e0a\u5c31\u662f\u672c\u6587\u7684\u5168\u90e8\u5185\u5bb9\uff0c\u5185\u5bb9\u7565\u591a\uff0c\u611f\u8c22\u4e00\u76f4\u9605\u8bfb\u5230\u6b64\u5904\uff01<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201611\/14.png\" align=\"absmiddle\"><\/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=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=6516\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=6516<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0a\u5468\u6211\u505a\u4e86\u4e2ademo\uff0c\u4f7f\u7528SVG\u5b9e\u73b0\u4e86\u4e00\u4e2a\u5f69\u6761\u5706\u73af\u5012\u8ba1\u65f6\u6548\u679c\uff0c\u4f7f\u7528SVG\u5b9e\u73b0\u7684\u4f18\u70b9\u662f\u517c\u5bb9\u6027\u975e\u5e38\u597d\uff0c\u4e0d\u8db3\u5728\u4e8e\u5b66\u4e60\u6210\u672c\u6bd4\u8f83\u9ad8\uff0c\u4e8e\u662f\u6211\u5c31\u7422\u78e8\u6709\u6ca1\u6709\u66f4\u7b80\u5355\u7684\u65b9\u6cd5\u5b9e\u73b0\u7c7b\u4f3c\u7684\u591a\u5f69\u5706\u73af\u6e10\u53d8\u6548\u679c\uff0c\u6700\u597d\u7eafCSS\u5c31\u80fd\u641e\u5b9a\u3002\u7ede\u5c3d\u8111\u6c41\u60f3\u51fa\u4e86\u4e0b\u9762\u4e09\u79cd\u5b9e\u73b0\u65b9\u6cd5\u2026\u2026<\/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":[887,583,959,1179,177,368,1180,1078,1181,302,460],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/6516"}],"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=6516"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/6516\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=6516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=6516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=6516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}