{"id":6521,"date":"2017-11-23T00:23:32","date_gmt":"2017-11-22T16:23:32","guid":{"rendered":"http:\/\/www.zhangxinxu.com\/wordpress\/?p=6521"},"modified":"2018-11-15T17:03:24","modified_gmt":"2018-11-15T09:03:24","slug":"css3-radial-gradient-syntax-example","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2017\/11\/css3-radial-gradient-syntax-example\/","title":{"rendered":"10\u4e2ademo\u793a\u4f8b\u5b66\u4f1aCSS3 radial-gradient\u5f84\u5411\u6e10\u53d8"},"content":{"rendered":"<p>by <a href=\"http:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=6521\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=6521<\/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\u8bed\u6cd5\u7ec6\u8282\u8bb0\u4e0d\u4f4f\u600e\u4e48\u529e\uff1f<\/h3>\n<p>\u5b9e\u9645\u5f00\u53d1\u7684\u65f6\u5019\uff0c\u5f53\u8981\u4f7f\u7528<code>radial-gradient<\/code>\u5f84\u5411\u6e10\u53d8\u7684\u65f6\u5019\uff0c\u8111\u4e2d\u4f1a\u6709\u5927\u6982\u7684\u8bed\u6cd5\uff0c\u4f46\u662f\u7ec6\u8282\u5374\u8bb0\u4e0d\u4f4f\uff0c\u4e8e\u662f\u60f3\u5feb\u6377\u627e\u4e2a\u6848\u4f8b\u770b\u770b\u5177\u4f53\u600e\u4e48\u7528\uff0c\u7136\u540e\u76f4\u63a5\u5957\u4e00\u4e0b\u3002\u901a\u5e38\u4e00\u756a\u641c\u7d22\uff0c\u4f1a\u53d1\u73b0\u867d\u7136\u662f\u4e2a\u7b80\u5355\u9700\u6c42\uff0c\u4f46\u662f\u6b63\u597d\u6ee1\u8db3\u8fd9\u4e2a\u9700\u6c42\u7684\u9875\u9762\u5374\u4e0d\u597d\u627e\uff0c\u4e71\u7cdf\u7cdf\u7684\u3002<\/p>\n<p>\u4e0b\u6b21\u9047\u5230\u8fd9\u79cd\u573a\u666f\uff0c\u76f4\u63a5\u6765\u672c\u7ad9\u641c\u201c\u5f84\u5411\u6e10\u53d8\u201d\uff0c\u6216\u8005\u76f4\u63a5\u641c\u7d22\u201c\u6e10\u53d8\u201d\uff0c\u5c31\u6709\u4e13\u95e8\u5c55\u793a<code>radial-gradient<\/code>\u5f84\u5411\u6e10\u53d8\u57fa\u672c\u8bed\u6cd5\u4f7f\u7528\u6848\u4f8b\u7684\u6587\u7ae0\u3002\u6587\u7ae0\u5171\u5c55\u793a\u4e8610\u4f8b\u5e38\u89c1\u4f7f\u7528\u6848\u4f8b\uff0c\u76f8\u4fe1\u4e00\u5b9a\u53ef\u4ee5\u8986\u76d6\u4f60\u7684\u4f7f\u7528\u573a\u666f\u7684\u3002<\/p>\n<p>\u9996\u5148\uff0c\u5047\u8bbe\u6211\u4eec\u4f7f\u7528\u540c\u4e00\u6bb5HTML\u4f5c\u4e3a\u793a\u610f\uff1a<\/p>\n<pre>&lt;div class=\"radial-gradient\"&gt;&lt;\/div&gt;<\/pre>\n<p>\u7136\u540e&#8230;<\/p>\n<h3>\u4e8c\u3001\u793a\u4f8b1\uff1a\u6700\u57fa\u7840\u6700\u7b80\u5355\u4f7f\u7528<\/h3>\n<p>CSS\u5982\u4e0b\uff1a<\/p>\n<pre>.radial-gradient {\n    width: 400px; height: 200px;\n    background: radial-gradient(yellow, red);\n}<\/pre>\n<p>\u6700\u7ec8\u6548\u679c\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-21_222122.jpg\" width=\"400\" height=\"200\" alt=\"\u6700\u57fa\u672c\u6e10\u53d8\u6548\u679c\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u82e5\u8981\u4eb2\u81ea\u786e\u8ba4\u6548\u679c\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"\/\/www.zhangxinxu.com\/study\/201711\/radial-gradient-simplest.html\" rel=\"noopener\" target=\"_blank\">radial-gradient\u5f84\u5411\u6e10\u53d8\u6700\u57fa\u672c\u8bed\u6cd5\u6548\u679cdemo<\/a><\/p>\n<p>\u53ef\u89c1\uff0c\u5bf9\u4e8e\u5f84\u5411\u6e10\u53d8\uff0c\u5728\u4e0d\u6307\u5b9a\u6e10\u53d8\u7c7b\u578b\u4ee5\u53ca\u4f4d\u7f6e\u7684\u60c5\u51b5\u4e0b\uff0c\u5176\u6e10\u53d8\u8ddd\u79bb\u548c\u4f4d\u7f6e\u662f\u7531\u5bb9\u5668\u7684\u5c3a\u5bf8\u51b3\u5b9a\u7684\u3002<\/p>\n<p>\u4f8b\u5982\u672c\u4f8b\u4e4b\u4e2d\uff0c\u5bb9\u5668\u7684\u5bbd\u9ad8\u6bd4\u662f2:1\uff0c\u6700\u7ec8\u6e10\u53d8\u5448\u73b0\u51fa\u6765\u7684\u5f62\u72b6\u4e5f\u662f\u4e00\u4e2a2:1\u7684\u692d\u5706\u5f62\uff0c\u5e76\u4e14\u6e10\u53d8\u989c\u8272\u81ea\u52a8\u7ec8\u6b62\u4e0e\u5bb9\u5668\u7684\u8fb9\u7f18\u3002<\/p>\n<p>\u539f\u7406\u793a\u610f\u5982\u4e0b\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201711\/radial-gradient-ray.png\" width=\"500\" height=\"234\" alt=\"\u5f84\u5411\u6e10\u53d8\u57fa\u7840\u6e10\u53d8\u539f\u7406\u793a\u610f\" class=\"alignnone\" \/><\/p>\n<p>\u5982\u679c\u6211\u4eec\u60f3\u6307\u5b9a\u6e10\u53d8\u7684\u5f62\u72b6\u662f\u4e00\u4e2a\u5706\u5f62\uff0c\u5f62\u72b6\u4e0d\u53d7\u5916\u90e8\u5bb9\u5668\u5c3a\u5bf8\u5f71\u54cd\uff0c\u53ef\u4ee5\u4f7f\u7528<code>circle<\/code>\u5173\u952e\u5b57\u3002<\/p>\n<h3>\u4e09\u3001\u793a\u4f8b2\uff1a\u7b80\u5355\u7684\u5706\u5f62\u6e10\u53d8<\/h3>\n<p>CSS\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>.radial-gradient {\n    width: 400px; height: 200px;\n    background: radial-gradient(circle, yellow, red);\n}<\/pre>\n<p>\u6700\u7ec8\u6548\u679c\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-21_225015.jpg\" width=\"400\" height=\"200\" alt=\u7b80\u5355\u7684\u5706\u5f62\u6e10\u53d8\u6548\u679c\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u82e5\u8981\u4eb2\u81ea\u786e\u8ba4\u6548\u679c\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"\/\/www.zhangxinxu.com\/study\/201711\/radial-gradient-circle-at-center.html\" rel=\"noopener\" target=\"_blank\">radial-gradient\u5f84\u5411\u6e10\u53d8\u7b80\u5355\u5706\u5f62\u6e10\u53d8\u6548\u679cdemo<\/a><\/p>\n<p>\u5176\u6e10\u53d8\u8303\u56f4\uff08\u6e10\u53d8\u7ed3\u675f\u7ebf\uff09\u793a\u610f\u5982\u4e0b\u56fe\uff0c\u4f1a\u53d1\u73b0\u65e2\u4e0d\u662f\u6309\u7167\u5bbd\u5ea6\u6765\u7684\uff0c\u4e5f\u4e0d\u662f\u6309\u7167\u9ad8\u5ea6\u6765\u7684\uff0c\u662f\u6309\u7167\u6700\u8fdc\u8fb9\u89d2\u8ddd\u79bb\u4f5c\u4e3a\u6e10\u53d8\u7ed3\u675f\u7ebf\u7684\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201711\/circle-gradient-end.png\" width=\"500\" height=\"500\" alt=\"\u5706\u5f62\u5f84\u5411\u6e10\u53d8\u8d77\u6b62\u4f4d\u7f6e\u793a\u610f\" class=\"alignnone\" \/><\/p>\n<p>\u8981\u8bc1\u660e\u4e0a\u9762\u7ed3\u8bba\u6bd4\u8f83\u7b80\u5355\uff0c\u6211\u4eec\u53ef\u4ee5\u8ba1\u7b97\u4e0b\u5bf9\u89d2\u7ebf\u4e00\u534a\u957f\u5ea6\uff0c\u4e3a\uff1aMath.sqrt(200*200 + 400*400) \u2248 223.6\uff0c\u4e8e\u662f\uff0c\u6211\u4eec\u8bbe\u7f6e\uff1a<\/p>\n<pre>.radial-gradient {\n    width: 400px; height: 200px;\n    background: radial-gradient(223.6px circle, yellow, red);\n}<\/pre>\n<p>\u4f1a\u53d1\u73b0\uff0c\u6700\u7ec8\u6548\u679c\u548c\u4e0a\u9762\u7684\u6548\u679c\u622a\u56fe\u51e0\u4e4e\u5c31\u662f\u4e00\u6a21\u4e00\u6837\u7684\u3002\u800c<code>200px<\/code>\u7684\u534a\u5f84\uff1a<\/p>\n<pre>.radial-gradient {\n    width: 400px; height: 200px;\n    background: radial-gradient(200px circle, yellow, red);\n}<\/pre>\n<p>\u53d6\u8272\u5c31\u4f1a\u53d1\u73b0\u8fb9\u7f18\u989c\u8272\u5dee\u5f02\u8f83\u5927\uff0c\u8bf4\u660e\u9ed8\u8ba4\u4e0d\u662f\u6309\u7167\u6700\u77ed\u8fb9\u6765\u6e32\u67d3\u7684\u3002<\/p>\n<h3>\u56db\u3001\u793a\u4f8b3\uff1a\u6307\u5b9a\u6e10\u53d8\u8d77\u59cb\u70b9\u4f4d\u7f6e<\/h3>\n<p>\u8d77\u59cb\u70b9\u4f4d\u7f6e\u53ef\u4ee5\u901a\u8fc7<code>at<\/code>\u6765\u6307\u5b9a\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>.radial-gradient {\n    width: 400px; height: 200px;\n    background: radial-gradient(circle at 50px 50px, yellow, red);\n}<\/pre>\n<p>\u6548\u679c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-22_000513.jpg\" width=\"400\" height=\"200\" alt=\"\u6e10\u53d8\u8d77\u59cb\u70b9\u5728\u5de6\u4e0a\u65b9\u6548\u679c\u622a\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u82e5\u8981\u4eb2\u81ea\u786e\u8ba4\u6548\u679c\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"\/\/www.zhangxinxu.com\/study\/201711\/radial-gradient-circle-at.html\" rel=\"noopener\" target=\"_blank\">\u5f84\u5411\u6e10\u53d8at\u786e\u5b9a\u6e10\u53d8\u8d77\u59cb\u70b9demo<\/a><\/p>\n<p>\u5982\u679c\u5e0c\u671b\u6e10\u53d8\u662f\u548c\u5bb9\u5668\u4fdd\u6301\u4e00\u81f4\u6bd4\u4f8b\u7684\u692d\u5706\uff0c\u5219<code>circle<\/code>\u53ef\u4ee5\u7f3a\u7701\uff0c\u4e5f\u5c31\u662f\u76f4\u63a5<code>radial-gradient(at 50px 50px, yellow, red)<\/code>\u4e5f\u662f\u53ef\u4ee5\u7684\u3002<\/p>\n<p><code>50px 50px<\/code>\u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528\u767e\u5206\u6bd4\u503c\u4ee3\u66ff\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>.radial-gradient {\n    width: 400px; height: 200px;\n    background: radial-gradient(circle at 12.5% 25%, yellow, red);\n}<\/pre>\n<p>\u6548\u679c\u662f\u4e00\u6a21\u4e00\u6837\u7684\u3002<\/p>\n<h3>\u4e94\u3001\u793a\u4f8b4\uff1a\u6307\u5b9a\u6e10\u53d8\u7ec8\u6b62\u70b9\u4f4d\u7f6e<\/h3>\n<p><code>radial-gradient<\/code>\u5f84\u5411\u6e10\u53d8\u652f\u63014\u4e2a\u5173\u952e\u5b57\u53ef\u4ee5\u6307\u5b9a\u6e10\u53d8\u7ec8\u6b62\u70b9\u4f4d\u7f6e\uff0c\u89c1\u4e0b\u8868\uff1a<\/p>\n<table class=\"params_table\" width=\"100%\" style=\"max-width:500px;\" cellspacing=\"1\">\n<tr>\n<th width=\"100\">\u5173\u952e\u5b57<\/th>\n<th>\u63cf\u8ff0<\/th>\n<\/tr>\n<tr>\n<td><code>closest-side<\/code><\/td>\n<td>\u6e10\u53d8\u4e2d\u5fc3\u8ddd\u79bb\u5bb9\u5668\u6700\u8fd1\u7684\u8fb9\u4f5c\u4e3a\u7ec8\u6b62\u4f4d\u7f6e\u3002<\/td>\n<\/tr>\n<tr>\n<td><code>closest-corner<\/code><\/td>\n<td>\u6e10\u53d8\u4e2d\u5fc3\u8ddd\u79bb\u5bb9\u5668\u6700\u8fd1\u7684\u89d2\u4f5c\u4e3a\u7ec8\u6b62\u4f4d\u7f6e\u3002<\/td>\n<\/tr>\n<tr>\n<td><code>farthest-side<\/code><\/td>\n<td>\u6e10\u53d8\u4e2d\u5fc3\u8ddd\u79bb\u5bb9\u5668\u6700\u8fdc\u7684\u8fb9\u4f5c\u4e3a\u7ec8\u6b62\u4f4d\u7f6e\u3002<\/td>\n<\/tr>\n<tr>\n<td><code>farthest-corner<\/code><\/td>\n<td>\u6e10\u53d8\u4e2d\u5fc3\u8ddd\u79bb\u5bb9\u5668\u6700\u8fdc\u7684\u89d2\u4f5c\u4e3a\u7ec8\u6b62\u4f4d\u7f6e\u3002<\/td>\n<\/tr>\n<\/table>\n<p>\u6839\u636e\u4e0a\u9762\u7684\u793a\u610f\u6548\u679c\u53ef\u4ee5\u770b\u51fa\u9ed8\u8ba4\u503c\u662f<code>farthest-corner<\/code>\u3002<\/p>\n<p>\u73b0\u5728\uff0c\u6211\u4eec\u5bf9CSS\u8fdb\u884c\u8c03\u6574\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre>.radial-gradient {\n    width: 400px; height: 200px;\n    background: radial-gradient(closest-side circle at 50px 50px, yellow, red);\n}<\/pre>\n<p>\u4e5f\u5c31\u662f\u5706\u5f62\u6e10\u53d8\u7ec8\u6b62\u4e8e\u6700\u77ed\u8fb9\uff0c\u7ed3\u679c\u6548\u679c\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-22_214418.jpg\" width=\"400\" height=\"200\" alt=\"\u8bbe\u7f6e\u6700\u77ed\u8fb9\u4e3a\u6e10\u53d8\u7ec8\u6b62\u70b9\u7684\u6548\u679c\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u82e5\u8981\u4eb2\u81ea\u786e\u8ba4\u6548\u679c\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/study\/201711\/radial-gradient-circle-closest-side.html\" rel=\"noopener\" target=\"_blank\">\u5f84\u5411\u6e10\u53d8\u7ec8\u6b62\u4e8e\u6700\u77ed\u8fb9demo<\/a><\/p>\n<h3>\u516d\u3001\u793a\u4f8b5\uff1a\u6307\u5b9a\u6e10\u53d8\u989c\u8272\u65ad\u70b9<\/h3>\n<p>\u5982\u679c\u6307\u5b9a\u591a\u4e2a\u989c\u8272\uff0c\u4f46\u672a\u6307\u5b9a\u5177\u4f53\u65ad\u70b9\u7684\u4f4d\u7f6e\uff0c\u5219\u8fd9\u4e9b\u989c\u8272\u4f1a\u5747\u5300\u5206\u914d0%~100%\u7684\u6e10\u53d8\u533a\u57df\uff0c\u4f8b\u5982\uff0c\u4e0b\u97624\u8272\u6e10\u53d8\uff1a<\/p>\n<pre>.radial-gradient {\n    width: 200px; height: 200px;\n    border: 1px solid silver;\n    background: radial-gradient(closest-side circle, yellow, orange, red, white);\n}<\/pre>\n<p>\u7ed3\u679c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-22_221246.png\" width=\"202\" height=\"202\" alt=\"4\u8272\u6e10\u53d8\u6548\u679c\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u4f46\u4ece\u8089\u773c\u89c6\u89c9\u6211\u4eec\u662f\u770b\u4e0d\u51fa\u662f\u4e0d\u662f\u5747\u5300\u5206\u914d\u6e10\u53d8\u533a\u57df\uff0c\u4f46\u662f\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5176\u4ed6\u65b9\u5f0f\u9a8c\u8bc1\u6211\u4eec\u7684\u89c2\u70b9\uff0c\u5982\u4e0b\u6307\u5b9a\u989c\u8272\u65ad\u70b9\u4f4d\u7f6e\u7684CSS\uff1a<\/p>\n<pre>.radial-gradient2 {\n    width: 200px; height: 200px;\n    border: 1px solid gray;\n    background: radial-gradient(closest-side circle, yellow, orange 33.33%, red 66.666%, white);\n}<\/pre>\n<p>\u7531\u4e8e\u6e10\u53d8\u989c\u8272\u9ed8\u8ba4\u7b2c\u4e00\u4e2a\u989c\u8272\u4f4d\u7f6e\u662f0%\uff0c\u6700\u540e\u4e00\u4e2a\u989c\u8272\u4f4d\u7f6e\u662f100%\uff0c\u56e0\u6b64\u4e0a\u9762<code>yellow<\/code>\u548c<code>white<\/code>\u7684\u65ad\u70b9\u4f4d\u7f6e\u53ef\u4ee5\u7f3a\u7701\u3002<\/p>\n<p>\u7136\u540e\u53d1\u73b0\u6548\u679c\u548c\u4e0a\u9762\u7684\u662f\u4e00\u81f4\u7684\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-22_221624.png\" width=\"202\" height=\"202\" alt=\"\u6307\u5b9a\u989c\u8272\u65ad\u70b9\u540e\u7684\u6548\u679c\u622a\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u6211\u505a\u4e86\u4e2a\u66f4\u80fd\u76f4\u89c2\u4f53\u9a8c\u4e00\u81f4\u6027\u7684demo\u9875\u9762\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/study\/201711\/radial-gradient-circle-colors.html\" rel=\"noopener\" target=\"_blank\">radial-gradient\u591a\u4e2a\u989c\u8272\u5747\u5300\u5206\u914d\u6e10\u53d8\u533a\u57dfdemo<\/a><\/p>\n<p>\u6309\u4e0b\u7b2c\u4e00\u4e2a\u5708\u5708\u6e10\u53d8\uff0c\u4f1a\u8ba9\u540e\u9762\u7684\u5708\u5708\u77ac\u95f4\u8986\u76d6\u5728\u4e0a\u9762\u3002\u5982\u679c\u4e24\u4e2a\u6e10\u53d8\u989c\u8272\u6709\u5dee\u5f02\uff0c\u6b64\u65f6\u8089\u773c\u53ef\u4ee5\u611f\u89c9\u5230\u660e\u663e\u53d8\u5316\uff1b\u4f46\u662f\u5b9e\u9645\u64cd\u4f5c\u4e0b\u6765\uff0c\u5c31\u597d\u50cf\u540e\u9762\u6e10\u53d8\u7a81\u7136\u6d88\u5931\u4e00\u822c\uff0c\u8fd9\u5c31\u8bf4\u660e\u4e0a\u4e0b\u4e24\u4e2a\u6e10\u53d8\u5b9e\u9645\u4e0a\u6548\u679c\u662f\u4e00\u81f4\u7684\u3002<\/p>\n<h3>\u4e03\u3001\u793a\u4f8b6\uff1a\u692d\u5706\u7c7b\u578b\u7684\u5f84\u5411\u6e10\u53d8<\/h3>\n<p>\u5bf9\u4e8e\u5706\u5f62\u754c\u9762\uff0c\u6211\u4eec\u53ea\u9700\u8981\u6307\u5b9a\u4e00\u4e2a\u534a\u5f84\u5c31\u53ef\u4ee5\u4e86\uff0c\u4f46\u662f\u5bf9\u4e8e\u692d\u5706\u7c7b\u578b\u7684\u5f84\u5411\u6e10\u53d8\uff0c\u6211\u4eec\u9700\u8981\u540c\u65f6\u6307\u5b9a\u6a2a\u8f74\u548c\u7eb5\u8f74\u7684\u957f\u5ea6\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>.radial-gradient {\n    width: 200px; height: 200px;\n    background: radial-gradient(50px 100px ellipse, transparent 40px, yellow 41px, red);\n}<\/pre>\n<p><code>50px 100px ellipse<\/code>\u4e2d\u7b2c\u4e00\u4e2a\u6570\u503c<code>50px<\/code>\u8868\u793a\u6a2a\u8f74\u534a\u5f84\uff0c<code>100px<\/code>\u8868\u793a\u7eb5\u8f74\u534a\u5f84\uff0c\u4e8e\u662f\u8fd9\u6bb5\u8bed\u53e5\u8868\u793a\u7ed8\u5236\u4e00\u4e2a\u957f\u5ea6<code>100px<\/code>\u9ad8\u5ea6<code>200px<\/code>\u7684\u692d\u5706\u3002<\/p>\n<p>\u6548\u679c\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-22_223217.png\" width=\"200\" height=\"200\" alt=\"\u692d\u5706\u6e10\u53d8\u6e10\u53d8\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u82e5\u8981\u4eb2\u81ea\u786e\u8ba4\u6548\u679c\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/study\/201711\/radial-gradient-ellipse.html\" rel=\"noopener\" target=\"_blank\">radial-gradient\u5f84\u5411\u6e10\u53d8\u692d\u5706\u6e10\u53d8demo<\/a><\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5728\u4e0a\u9762\u793a\u610fCSS\u4ee3\u7801\u4e2d\uff0c\u900f\u660e\u5230\u9ec4\u8272\u5206\u754c\u90a3\u91cc\u6709\u4e00\u4e2a<code>1px<\/code>\u7684\u504f\u5dee\u8fc7\u6e21\uff0c\u4e5f\u5c31\u662f<code>transparent 40px, yellow 41px<\/code>\u4e2d<code>yellow<\/code>\u662f<code>41px<\/code>\uff0c\u800c\u4e0d\u662f\u8bbe\u7f6e\u7684<code>40px<\/code>\uff0c\u539f\u56e0\u5728\u4e8e\u5728Chrome\u4e0b\uff0c\u5982\u679c\u989c\u8272\u76f4\u63a5<code>0<\/code>\u504f\u5dee\u8fc7\u6e21\uff0c\u4f1a\u6709\u6bd4\u8f83\u4e25\u91cd\u7684\u952f\u9f7f\uff0c\u7c7b\u4f3c\u4e0b\u56fe\u8fd9\u6837\uff08\u80cc\u666f\u8272\u8bbe\u4e3a<code>#333<\/code>\uff09\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-22_223643.png\" width=\"200\" height=\"200\" alt=\"Chrome\u6d4f\u89c8\u5668\u4e0b\u5f84\u5411\u6e10\u53d8\u7684\u952f\u9f7f\" class=\"alignnone\" \/><\/p>\n<p>\u901a\u8fc7\u67091\u50cf\u7d20\u6216\u8005\u534a\u50cf\u7d20\u7684\u8fc7\u6e21\u7f13\u51b2\u53ef\u4ee5\u6709\u6548\u907f\u514d\u952f\u9f7f\u7684\u51fa\u73b0\u3002<\/p>\n<h3>\u516b\u3001\u793a\u4f8b7\uff1a\u53ef\u7d2f\u52a0\u7684\u5f84\u5411\u6e10\u53d8\u80cc\u666f\u56fe<\/h3>\n<p>\u6211\u4eec\u53ef\u4ee5\u628a\u591a\u4e2a\u5f84\u5411\u6e10\u53d8\u7d2f\u52a0\u5728\u4e00\u8d77\u5b9e\u73b0\u67d0\u4e9b\u6548\u679c\uff0c\u4f8b\u5982\u4e0b\u9762CSS\uff1a<\/p>\n<pre>.radial-gradient {\n    width: 200px; height: 200px;\n    background: radial-gradient(50px 100px ellipse, transparent 40px, yellow 41px, red 49px, transparent 50px),\n                radial-gradient(30px circle, red, red 29px, transparent 30px);\n}<\/pre>\n<p>\u5b9e\u73b0\u4e86\u201c\u90aa\u738b\u771f\u773c\u201d\u6548\u679c\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-22_224944.jpg\" width=\"200\" height=\"187\" alt=\"\u90aa\u738b\u771f\u773c\" class=\"alignnone\" \/> <img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-22_225058.png\" width=\"106\" height=\"205\" alt=\"\u201c\u90aa\u738b\u771f\u773c\u201d\u5b9e\u73b0\u6548\u679c\u622a\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u82e5\u8981\u4eb2\u81ea\u611f\u53d7\u6548\u679c\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/study\/201711\/radial-gradient-multiple.html\" rel=\"noopener\" target=\"_blank\">radial-gradient\u591a\u4e2a\u5f84\u5411\u6e10\u53d8\u7d2f\u52a0demo<\/a><\/p>\n<h3>\u4e5d\u3001\u793a\u4f8b8\uff1a\u6e10\u53d8\u80cc\u666f\u7684\u5c3a\u5bf8\u63a7\u5236<\/h3>\n<p>\u914d\u5408<code>background-size<\/code>\u7684\u5c3a\u5bf8\u63a7\u5236\u548c\u80cc\u666f\u91cd\u590d\u7279\u6027\uff0c\u6211\u4eec\u53ef\u4ee5\u5b9e\u73b0\u6e10\u53d8\u5f0f\u7684\u590d\u6742\u7eb9\u7406\u6548\u679c\uff1a<\/p>\n<pre>.radial-gradient {\n    width: 200px; height: 200px;\n    background: radial-gradient(5px 10px ellipse, transparent 4px, yellow 5px, red 6px, transparent 7px),\n                radial-gradient(3px circle, red, red 3px, transparent 4px);\n    background-size: 25px;\n}<\/pre>\n<p>\u4e8e\u662f\u5c31\u53ef\u4ee5\u770b\u5230\u4e00\u5927\u6ce2\u5199\u8f6e\u773c\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-22_230329.png\" width=\"197\" height=\"207\" alt=\"\u91cd\u590d\u7684\u773c\u775b\u7eb9\u7406\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u901a\u5e38\u6211\u4eec\u4f7f\u7528\u5f84\u5411\u6e10\u53d8\u6784\u5efa\u4e00\u4e9b\u7b80\u5355\u5b9e\u7528\u56fe\u5f62\u7684\u65f6\u5019\uff0c<code>background-size<\/code>\u5f80\u5f80\u662f\u5173\u952e\u5c5e\u6027\uff0c\u4f8b\u5982\uff0c\u6211\u4eec\u8981\u5b9e\u73b0\u4e2a\u6c34\u6ce2\u6548\u679c\uff0c\u53ef\u4ee5\u8fd9\u6837\uff1a<\/p>\n<pre>.radial-gradient {\n    width: 200px; height: 100px;\n    background: red;\n    position: relative;\n}\n.radial-gradient:after {\n    content: '';\n    position: absolute;\n    height: 10px;\n    left:0 ; right: 0;\n    bottom: -10px;\n    background: radial-gradient(20px 15px ellipse at top, red 10px, transparent 11px);\n    background-size: 20px 10px;\n}<\/pre>\n<p>\u7136\u540e\u5c31\u6709\u4e0b\u56fe\u6240\u793a\u7684\u6548\u679c\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-22_235300.png\" width=\"206\" height=\"112\" alt=\"\u5e95\u90e8\u6c34\u6ce2\u6548\u679c\" class=\"alignnone\" \/><\/p>\n<p>\u5b9e\u65f6\u6548\u679c\u4f53\u9a8c\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/study\/201711\/radial-gradient-wave.html\" rel=\"noopener\" target=\"_blank\">\u5f84\u5411\u6e10\u53d8\u5c3a\u5bf8\u63a7\u5236\u4e0b\u7684\u6ce2\u7eb9\u6548\u679cdemo<\/a><\/p>\n<h3>\u5341\u3001\u793a\u4f8b9\uff1a\u53ef\u91cd\u590d\u7684\u5f84\u5411\u6e10\u53d8<\/h3>\n<p>\u5982\u679c\u60f3\u8981\u5b9e\u73b0\u53ef\u91cd\u590d\u7684\u5f84\u5411\u6e10\u53d8\uff0c\u4ea6\u53ef\u4ee5\u4f7f\u7528\u539f\u751f\u7684<code>repeating-radial-gradient()<\/code>\u65b9\u6cd5\uff0c\u7279\u522b\u9002\u5408\u5b9e\u73b0\u4ece\u4e2d\u5fc3\u6269\u6563\u7684\u5149\u6ce2\u6548\u679c\u3002<\/p>\n<p>\u7136\u800c\uff0c\u76f8\u6bd4\u91cd\u590d\u7ebf\u6027\u6e10\u53d8<code>repeating-linear-gradient()<\/code>\u65b9\u6cd5\uff0c<code>repeating-radial-gradient()<\/code>\u7684\u5b9e\u9645\u5e94\u7528\u573a\u666f\u5b9e\u9645\u4e0a\u5f88\u6709\u9650\u3002\u56e0\u4e3a\uff0c\u5b9e\u9645\u5f00\u53d1\u7684\u65f6\u5019\uff0c\u6211\u4eec\u5f88\u5c11\u7528\u5230\u4ece\u4e2d\u5fc3\u6269\u6563\u7684\u5149\u6ce2\u6548\u679c\u3002<\/p>\n<p>\u9664\u4e86\u4e00\u4e9b\u672c\u8eab\u5c31\u662f\u6ce2\u7eb9\u7c7b\u578b\u6548\u679c\uff0c\u5982\u6c34\u6ce2\uff0c\u58f0\u6ce2\u6216\u8005\u5531\u7247\u7eb9\u7406\uff1a<\/p>\n<p>\u5982\u4e0bCSS\uff08\u53d6\u81ea<a href=\"https:\/\/codepen.io\/thebabydino\/embed\/HjJlL\" rel=\"nofollow\" target=\"_blank\">https:\/\/codepen.io\/thebabydino\/embed\/HjJlL<\/a>\uff09\uff1a<\/p>\n<pre>.radial-gradient {\n    position: relative;\n    width: 262px; height: 262px;\n    border-radius: 50%;\n    background: linear-gradient(30deg, transparent 40%, rgba(42, 41, 40, .85) 40%) no-repeat 100% 0, linear-gradient(60deg, rgba(42, 41, 40, .85) 60%, transparent 60%) no-repeat 0 100%, repeating-radial-gradient(#2a2928, #2a2928 4px, #ada9a0 5px, #2a2928 6px);\n    background-size: 50% 100%, 100% 50%, 100% 100%;\n}\n.radial-gradient:after {\n    position: absolute;\n    top: 50%; left: 50%;\n    margin: -35px;\n    border: solid 1px #d9a388;\n    width: 68px; height: 68px;\n    border-radius: 50%;\n    box-shadow: 0 0 0 4px #da5b33, inset 0 0 0 27px #da5b33;\n    background: #b5ac9a;\n    content: '';\n}<\/pre>\n<p>\u6548\u679c\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-22_235448.png\" width=\"270\" height=\"274\" alt=\"\u80f6\u7247\u5531\u7247\u6548\u679c\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u6548\u679c\u4f53\u9a8c\uff0c\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/study\/201711\/radial-gradient-repeating.html\" rel=\"noopener\" target=\"_blank\">\u53ef\u91cd\u590d\u5f84\u5411\u6e10\u53d8\u4e0b\u7684\u80f6\u7247\u6548\u679c<\/a><\/p>\n<h3>\u5341\u4e00\u3001\u793a\u4f8b10\uff1a\u4f5c\u4e3aborder-image\u7684\u5f84\u5411\u6e10\u53d8<\/h3>\n<p>\u5f84\u5411\u6e10\u53d8\u4e0d\u4ec5\u53ef\u4ee5\u4f5c\u4e3a<code>background<\/code>\u7684\u80cc\u666f\u56fe\uff0c\u8fd8\u53ef\u4ee5\u4f5c\u4e3a<code>border-image<\/code>\u7684\u8fb9\u6846\u56fe\u4f7f\u7528\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<pre>.radial-gradient {\n    width: 100px; height: 100px;\n    border: 50px solid;\n    border-image: radial-gradient(circle, transparent 50px, yellow 51px, red) 50 stretch;\n}<\/pre>\n<p>\u6548\u679c\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201711\/2017-11-23_001903.png\" width=\"201\" height=\"200\" alt=\"border-image\u4f7f\u7528\u5f84\u5411\u6e10\u53d8\u6548\u679c\" class=\"alignnone\" \/><\/p>\n<p>\u5929\u7136\u9542\u7a7a\u6548\u679c\uff0c\u53ea\u53ef\u60dc<code>border-image<\/code>\u662f\u65e0\u6cd5\u548c<code>border-radius<\/code>\u540c\u65f6\u751f\u6548\u7684\uff0c\u5426\u5219\uff0c<code>border-image<\/code>\u53ef\u5c31\u8981\u725b\u70b8\u5929\u4e86\u3002<\/p>\n<p>\u6548\u679c\u4f53\u9a8c\uff0c\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/study\/201711\/radial-gradient-border-image.html\" rel=\"noopener\" target=\"_blank\">radial-gradient\u5f84\u5411\u6e10\u53d8\u4e0eborder-image\u5448\u73b0demo<\/a><\/p>\n<h3>\u5341\u4e8c\u3001\u7ed3\u675f\u8bed<\/h3>\n<p>\u6211\u771f\u80fd\u5199\uff01<\/p>\n<p><img decoding=\"async\" src=\"\/\/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=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=6521\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=6521<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b9e\u9645\u5f00\u53d1\u7684\u65f6\u5019\uff0c\u5f53\u8981\u4f7f\u7528<code>radial-gradient<\/code>\u5f84\u5411\u6e10\u53d8\u7684\u65f6\u5019\uff0c\u8111\u4e2d\u4f1a\u6709\u5927\u6982\u7684\u8bed\u6cd5\uff0c\u4f46\u662f\u7ec6\u8282\u5374\u8bb0\u4e0d\u4f4f\uff0c\u4e8e\u662f\u60f3\u5feb\u6377\u627e\u4e2a\u6848\u4f8b\u770b\u770b\u5177\u4f53\u600e\u4e48\u7528\uff0c\u7136\u540e\u76f4\u63a5\u5957\u4e00\u4e0b\uff0c\u672c\u6587\u5c31\u662f\u6ee1\u8db3\u7c7b\u4f3c\u6b64\u9700\u6c42\u800c\u5199\uff0c\u5171\u5c55\u793a\u4e8610\u4f8b\u5e38\u89c1\u4f7f\u7528\u6848\u4f8b\uff0c\u76f8\u4fe1\u4e00\u5b9a\u53ef\u4ee5\u8986\u76d6\u4f60\u7684\u4f7f\u7528\u573a\u666f\u7684\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":[298,177,1181,868,189,421],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/6521"}],"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=6521"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/6521\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=6521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=6521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=6521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}