{"id":88798,"date":"2024-04-07T17:38:19","date_gmt":"2024-04-07T09:38:19","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/88798.html"},"modified":"2024-04-07T17:38:21","modified_gmt":"2024-04-07T09:38:21","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8css%e5%88%9b%e5%bb%ba%e6%b8%90%e5%8f%98%e8%83%8c%e6%99%af","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/88798.html","title":{"rendered":"\u5982\u4f55\u4f7f\u7528CSS\u521b\u5efa\u6e10\u53d8\u80cc\u666f"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/02172804\/611bae78-dcc3-482f-af1e-e2043b8ffd55.webp\" alt=\"\u5982\u4f55\u4f7f\u7528CSS\u521b\u5efa\u6e10\u53d8\u80cc\u666f\" \/><\/p>\n<p><p>\u6e10\u53d8\u80cc\u666f\u662f\u7f51\u9875\u8bbe\u8ba1\u4e2d\u4e00\u4e2a\u6d41\u884c\u7684\u89c6\u89c9\u5143\u7d20\uff0c<strong>\u4f7f\u7528CSS\u521b\u5efa\u6e10\u53d8\u80cc\u666f<\/strong>\u7684\u65b9\u6cd5\u4e3b\u8981\u6709\u4e24\u79cd\uff1a\u7ebf\u6027\u6e10\u53d8\uff08linear-gradient\uff09\u548c\u5f84\u5411\u6e10\u53d8\uff08radial-gradient\uff09\u3002\u8981\u521b\u5efa\u6e10\u53d8\u80cc\u666f\uff0c\u60a8\u9700\u8981\u5b9a\u4e49\u6e10\u53d8\u7684\u7c7b\u578b\u3001\u989c\u8272\u4ee5\u53ca\u989c\u8272\u53d8\u5316\u7684\u65b9\u5411\u6216\u5f62\u72b6\u3002<strong>\u7ebf\u6027\u6e10\u53d8\u6cbf\u76f4\u7ebf\u65b9\u5411\u8fc7\u6e21\uff0c\u60a8\u53ef\u4ee5\u6307\u5b9a\u6e10\u53d8\u7684\u65b9\u5411\uff08\u5982\u4ece\u9876\u90e8\u5230\u5e95\u90e8\uff09\u6216\u89d2\u5ea6\uff1b\u800c\u5f84\u5411\u6e10\u53d8\u5219\u662f\u4ece\u4e00\u4e2a\u70b9\u5411\u5916\u5706\u5f62\u6269\u6563\u3002<\/strong> \u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u63a2\u8ba8\u5982\u4f55\u5229\u7528\u8fd9\u4e24\u79cd\u6e10\u53d8\u65b9\u5f0f\u6765\u4e30\u5bcc\u60a8\u7684\u7f51\u9875\u80cc\u666f\u8bbe\u8ba1\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u7ebf\u6027\u6e10\u53d8\uff08LINEAR GRADIENT\uff09<\/h3>\n<\/p>\n<p><p>\u7ebf\u6027\u6e10\u53d8\u5728\u7f51\u9875\u8bbe\u8ba1\u4e2d\u975e\u5e38\u5e38\u89c1\uff0c\u5b83\u5141\u8bb8\u989c\u8272\u6cbf\u76f4\u7ebf\u8f74\u7ebf\u6e10\u53d8\u3002\u521b\u5efa\u7ebf\u6027\u6e10\u53d8\u7684\u57fa\u672c\u8bed\u6cd5\u662f <code>background-image: linear-gradient(direction, color-stop1, color-stop2,...);<\/code>\u3002<\/p>\n<\/p>\n<p><h4>\u8bbe\u5b9a\u65b9\u5411\u4e0e\u989c\u8272<\/h4>\n<\/p>\n<p><p>\u9996\u5148\u51b3\u5b9a\u6e10\u53d8\u7684\u65b9\u5411\uff0c\u53ef\u4ee5\u662f\u5177\u4f53\u7684\u89d2\u5ea6\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u5173\u952e\u8bcd\uff08\u5982 &#039;to top&#039;\u3001&#039;to right&#039; \u7b49\uff09\u3002\u7136\u540e\uff0c\u4f60\u53ef\u4ee5\u6307\u5b9a\u4e24\u4e2a\u6216\u66f4\u591a\u989c\u8272\u65ad\u70b9\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-css\">.my-gradient {<\/p>\n<p>  background-image: linear-gradient(to bottom, #33ccff, #ff99cc);<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c#33ccff \u548c #ff99cc \u4e4b\u95f4\u7684\u6e10\u53d8\u5c06\u4ece\u4e0a\u5230\u4e0b\u7ed8\u5236\u3002<\/p>\n<\/p>\n<p><h4>\u4f7f\u7528\u89d2\u5ea6\u6765\u5b9a\u4e49\u6e10\u53d8<\/h4>\n<\/p>\n<p><p>\u9664\u4e86\u5173\u952e\u8bcd\uff0c\u60a8\u4e5f\u53ef\u4ee5\u4f7f\u7528\u89d2\u5ea6\u6765\u5b9a\u4e49\u6e10\u53d8\u7684\u65b9\u5411\u3002\u89d2\u5ea60deg\u8868\u793a\u4ece\u4e0b\u5230\u4e0a\u7684\u6e10\u53d8\uff0c\u89d2\u5ea6\u589e\u5927\u5219\u8868\u793a\u987a\u65f6\u9488\u65cb\u8f6c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-css\">.my-gradient {<\/p>\n<p>  background-image: linear-gradient(45deg, #33ccff, #ff99cc);<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u91cc\u7684\u6e10\u53d8\u4ece\u5de6\u4e0b\u89d2\u5230\u53f3\u4e0a\u89d2\uff0c\u56e0\u4e3a\u6e10\u53d8\u7684\u65b9\u5411\u662f45\u5ea6\u89d2\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u5f84\u5411\u6e10\u53d8\uff08RADIAL GRADIENT\uff09<\/h3>\n<\/p>\n<p><p>\u5f84\u5411\u6e10\u53d8\u7684\u989c\u8272\u4ece\u4e00\u4e2a\u70b9\u5411\u5916\u53d1\u6563\u3002\u4f7f\u7528\u5f84\u5411\u6e10\u53d8\u53ef\u4ee5\u521b\u5efa\u7c7b\u4f3c\u4e8e\u5149\u6655\u6216\u8005\u6f29\u6da1\u7684\u6548\u679c\u3002\u57fa\u672c\u8bed\u6cd5\u662f <code>background-image: radial-gradient(shape size at position, start-color, ..., last-color);<\/code>\u3002<\/p>\n<\/p>\n<p><h4>\u6307\u5b9a\u5f62\u72b6\u4e0e\u5c3a\u5bf8<\/h4>\n<\/p>\n<p><p>\u5f84\u5411\u6e10\u53d8\u7684\u5f62\u72b6\u53ef\u4ee5\u662f\u5706\u5f62\uff08circle\uff09\u6216\u692d\u5706\u5f62\uff08ellipse\uff09\u3002\u60a8\u4e5f\u53ef\u4ee5\u6307\u5b9a\u6e10\u53d8\u7684\u5c3a\u5bf8\uff0c\u5982 &#039;closest-side&#039;, &#039;farthest-corner&#039; \u7b49\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-css\">.my-radial-gradient {<\/p>\n<p>  background-image: radial-gradient(circle at center, #ffffff, #000000);<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u4f8b\u5b50\u5c06\u521b\u5efa\u4e00\u4e2a\u4ee5\u4e2d\u5fc3\u4e3a\u8d77\u70b9\u7684\u5706\u5f62\u6e10\u53d8\uff0c\u4ece\u767d\u8272\u8fc7\u6e21\u5230\u9ed1\u8272\u3002<\/p>\n<\/p>\n<p><h4>\u81ea\u5b9a\u4e49\u6e10\u53d8\u4f4d\u7f6e\u4e0e\u989c\u8272\u8fc7\u6e21<\/h4>\n<\/p>\n<p><p>\u60a8\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539 at position \u5c5e\u6027\u6765\u79fb\u52a8\u6e10\u53d8\u7684\u4e2d\u5fc3\u4f4d\u7f6e\u3002\u540c\u65f6\u4e5f\u53ef\u4ee5\u81ea\u7531\u5730\u6dfb\u52a0\u591a\u4e2a\u989c\u8272\u65ad\u70b9\u4ee5\u5b9e\u73b0\u590d\u6742\u7684\u989c\u8272\u8fc7\u6e21\u6548\u679c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-css\">.my-radial-gradient {<\/p>\n<p>  background-image: radial-gradient(circle at 100px 100px, #ffffff, #ffccff, #000000);<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u5706\u5fc3\u4f4d\u4e8e\uff08100px, 100px\uff09\u7684\u5706\u5f62\u6e10\u53d8\uff0c\u989c\u8272\u4ece\u767d\u8272\u8fc7\u6e21\u5230\u7c89\u8272\u518d\u5230\u9ed1\u8272\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u6e10\u53d8\u7684\u5e94\u7528\u4e0e\u8c03\u6574<\/h3>\n<\/p>\n<p><p>\u6e10\u53d8\u53ef\u4ee5\u5e94\u7528\u4e8e\u4efb\u4f55\u9700\u8981\u80cc\u666f\u7684\u5143\u7d20\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u5b83\u4f5c\u4e3a\u6309\u94ae\u7684\u80cc\u666f\u3001\u9875\u9762\u7684banner\u6216\u6574\u4e2a\u9875\u9762\u80cc\u666f\u3002\u540c\u65f6\uff0cCSS\u4e5f\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u5c5e\u6027\u6765\u8c03\u6574\u6e10\u53d8\u6548\u679c\u3002<\/p>\n<\/p>\n<p><h4>\u521b\u5efa\u91cd\u590d\u7684\u6e10\u53d8\u80cc\u666f<\/h4>\n<\/p>\n<p><p>\u60f3\u8981\u521b\u5efa\u91cd\u590d\u7684\u6e10\u53d8\u6548\u679c\uff0c\u53ef\u4ee5\u4f7f\u7528\u91cd\u590d\u6e10\u53d8\u51fd\u6570 <code>repeating-linear-gradient()<\/code> \u548c <code>repeating-radial-gradient()<\/code>\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-css\">.my-repeating-gradient {<\/p>\n<p>  background-image: repeating-linear-gradient(<\/p>\n<p>    45deg,<\/p>\n<p>    #33ccff,<\/p>\n<p>    #33ccff 10px,<\/p>\n<p>    #ff99cc 10px,<\/p>\n<p>    #ff99cc 20px<\/p>\n<p>  );<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4ee5\u4e0a\u4ee3\u7801\u5c06\u521b\u5efa\u4e00\u4e2a45\u5ea6\u7684\u6761\u7eb9\u6548\u679c\uff0c\u989c\u8272\u5728 #33ccff \u548c #ff99cc \u4e4b\u95f4\u4ea4\u66ff\u3002<\/p>\n<\/p>\n<p><h4>\u5229\u7528\u989c\u8272\u505c\u9760\u5b9e\u73b0\u66f4\u5e73\u6ed1\u7684\u8fc7\u6e21<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7\u5728\u6e10\u53d8\u4e2d\u63d2\u5165\u591a\u4e2a\u989c\u8272\u65ad\u70b9\uff0c\u53ef\u4ee5\u8ba9\u989c\u8272\u53d8\u5316\u66f4\u52a0\u5e73\u6ed1\u548c\u5fae\u5999\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-css\">.my-smooth-gradient {<\/p>\n<p>  background-image: linear-gradient(<\/p>\n<p>    to bottom,<\/p>\n<p>    #33ccff,<\/p>\n<p>    #66ccff 50%,<\/p>\n<p>    #99ccff 75%,<\/p>\n<p>    #ccffff<\/p>\n<p>  );<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u6e10\u53d8\u4f7f\u7528\u4e86\u591a\u4e2a\u84dd\u8272\u7cfb\u7684\u989c\u8272\u65ad\u70b9\uff0c\u521b\u9020\u4e86\u4e00\u4e2a\u66f4\u5e73\u6ed1\u7684\u4ece\u6d45\u5230\u6df1\u7684\u84dd\u8272\u8fc7\u6e21\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u6e10\u53d8\u6548\u679c\u7684\u9ad8\u7ea7\u5e94\u7528<\/h3>\n<\/p>\n<p><p>\u5728\u638c\u63e1\u4e86\u57fa\u7840\u7684\u6e10\u53d8\u521b\u5efa\u6280\u5de7\u540e\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u4e00\u4e9b\u9ad8\u7ea7\u5e94\u7528\uff0c\u5982\u6e10\u53d8\u7684\u53e0\u52a0\u3001\u900f\u660e\u5ea6\u53d8\u5316\u548c\u590d\u6742\u7684\u56fe\u6848\u3002<\/p>\n<\/p>\n<p><h4>\u53e0\u52a0\u591a\u91cd\u6e10\u53d8<\/h4>\n<\/p>\n<p><p>CSS\u5141\u8bb8\u4f60\u5728\u540c\u4e00\u4e2a\u5143\u7d20\u4e0a\u53e0\u52a0\u591a\u4e2a\u6e10\u53d8\u80cc\u666f\uff0c\u8fd9\u6837\u53ef\u4ee5\u521b\u9020\u66f4\u52a0\u590d\u6742\u7684\u89c6\u89c9\u6548\u679c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-css\">.my-multi-gradient {<\/p>\n<p>  background-image: linear-gradient(<\/p>\n<p>      to right,<\/p>\n<p>      rgba(255, 0, 0, 0.5),<\/p>\n<p>      rgba(255, 0, 0, 0) 50%<\/p>\n<p>    ),<\/p>\n<p>    linear-gradient(<\/p>\n<p>      to bottom,<\/p>\n<p>      rgba(0, 255, 0, 0.5),<\/p>\n<p>      rgba(0, 255, 0, 0) 50%<\/p>\n<p>    ),<\/p>\n<p>    linear-gradient(<\/p>\n<p>      45deg,<\/p>\n<p>      blue,<\/p>\n<p>      transparent<\/p>\n<p>    );<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6bb5\u4ee3\u7801\u521b\u5efa\u4e86\u4e00\u4e2a\u5305\u542b\u4e09\u4e2a\u7ebf\u6027\u6e10\u53d8\u7684\u80cc\u666f\uff0c\u7531\u4e8e\u989c\u8272\u4e2d\u4f7f\u7528\u4e86\u900f\u660e\u5ea6\uff0c\u6240\u4ee5\u6e10\u53d8\u4e4b\u95f4\u53ef\u4ee5\u76f8\u4e92\u53e0\u52a0\u3002<\/p>\n<\/p>\n<p><h4>\u521b\u5efa\u590d\u6742\u7684\u56fe\u6848<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7\u5de7\u5999\u5730\u5229\u7528\u6e10\u53d8\u548c\u5b83\u4eec\u7684\u53e0\u52a0\uff0c\u4f60\u53ef\u4ee5\u521b\u5efa\u51fa\u5404\u79cd\u590d\u6742\u7684\u80cc\u666f\u56fe\u6848\uff0c\u4f8b\u5982\u6761\u7eb9\u3001\u683c\u5b50\u7b49\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-css\">.my-pattern-gradient {<\/p>\n<p>  background-image: linear-gradient(<\/p>\n<p>      90deg,<\/p>\n<p>      transparent 50%,<\/p>\n<p>      gray 50%<\/p>\n<p>    ),<\/p>\n<p>    linear-gradient(<\/p>\n<p>      transparent 50%,<\/p>\n<p>      gray 50%<\/p>\n<p>    );<\/p>\n<p>  background-size: 20px 20px;<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4ee5\u4e0a\u4ee3\u7801\u4f7f\u7528\u4e86\u4e24\u4e2a\u5782\u76f4\u7684\u6e10\u53d8\u548c\u76f8\u5e94\u7684\u80cc\u666f\u5927\u5c0f\u8bbe\u7f6e\u6765\u751f\u6210\u4e00\u4e2a\u683c\u5b50\u56fe\u6848\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u4f18\u5316\u4e0e\u517c\u5bb9\u6027<\/h3>\n<\/p>\n<p><p>\u6e10\u53d8\u80cc\u666f\u5728\u89c6\u89c9\u4e0a\u6781\u5177\u5438\u5f15\u529b\uff0c\u4f46\u4e5f\u9700\u8981\u6ce8\u610f\u517c\u5bb9\u6027\u548c\u6e32\u67d3\u6027\u80fd\u3002\u4f7f\u7528\u73b0\u4ee3\u7684\u524d\u7aef\u6280\u672f\u53ef\u4ee5\u786e\u4fdd\u6e10\u53d8\u770b\u8d77\u6765\u5728\u6240\u6709\u6d4f\u89c8\u5668\u4e2d\u90fd\u4e00\u6837\u7f8e\u89c2\uff0c\u5e76\u4e14\u4e0d\u4f1a\u5bf9\u9875\u9762\u6027\u80fd\u4ea7\u751f\u8d1f\u9762\u5f71\u54cd\u3002<\/p>\n<\/p>\n<p><h4>\u517c\u5bb9\u6027<\/h4>\n<\/p>\n<p><p>\u4e3a\u4e86\u786e\u4fdd\u5728\u65e7\u7248\u672c\u6d4f\u89c8\u5668\u4e2d\u4e5f\u80fd\u663e\u793a\u6e10\u53d8\u6548\u679c\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u6d4f\u89c8\u5668\u524d\u7f00\uff0c\u5982 <code>-webkit-<\/code>\u3001<code>-moz-<\/code>\u7b49\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-css\">.my-gradient-compatibility {<\/p>\n<p>  background-image: -webkit-linear-gradient(to right, #33ccff, #ff99cc);<\/p>\n<p>  background-image: linear-gradient(to right, #33ccff, #ff99cc);<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u6b64\u4f8b\u4e2d\uff0c\u9996\u5148\u4f7f\u7528\u4e86 Webkit \u5185\u6838\u7684\u6d4f\u89c8\u5668\u524d\u7f00\uff0c\u968f\u540e\u662f\u6807\u51c6\u8bed\u6cd5\u3002<\/p>\n<\/p>\n<p><h4>\u6027\u80fd\u4f18\u5316<\/h4>\n<\/p>\n<p><p>\u6e10\u53d8\u7531\u6d4f\u89c8\u5668\u5728\u6e32\u67d3\u65f6\u751f\u6210\uff0c\u56e0\u6b64\u4e0d\u4f1a\u589e\u52a0\u989d\u5916\u7684\u4e0b\u8f7d\u65f6\u95f4\uff0c\u4f46\u590d\u6742\u7684\u6e10\u53d8\u53ef\u80fd\u4f1a\u589e\u52a0\u6d4f\u89c8\u5668\u7684\u8ba1\u7b97\u8d1f\u8377\u3002\u4f18\u5316\u5efa\u8bae\u5305\u62ec\u9650\u5236\u6e10\u53d8\u4e2d\u989c\u8272\u65ad\u70b9\u7684\u6570\u91cf\uff0c\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u590d\u6742\u5ea6\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u603b\u7ed3\u4e0e\u5b9e\u8df5\u5efa\u8bae<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u60a8\u5e94\u8be5\u4e86\u89e3\u5982\u4f55\u4f7f\u7528CSS\u521b\u5efa\u7ebf\u6027\u548c\u5f84\u5411\u7684\u6e10\u53d8\u80cc\u666f\uff0c\u5e76\u5982\u4f55\u5c06\u5b83\u4eec\u7528\u4e8e\u521b\u9020\u6709\u8da3\u7684\u8bbe\u8ba1\u6548\u679c\u4ee5\u53ca\u5728\u4e0d\u540c\u573a\u666f\u4e2d\u7684\u5e94\u7528\u3002<strong>\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u5efa\u8bae\u5148\u8fdb\u884c\u5145\u5206\u7684\u6d4b\u8bd5\uff0c\u4ee5\u786e\u4fdd\u6e10\u53d8\u6548\u679c\u5728\u6240\u6709\u76ee\u6807\u6d4f\u89c8\u5668\u4e2d\u6e32\u67d3\u6b63\u786e\uff0c\u5e76\u5728\u6027\u80fd\u548c\u517c\u5bb9\u6027\u4e4b\u95f4\u5bfb\u627e\u5e73\u8861\u70b9\u3002<\/strong> \u793e\u533a\u4e5f\u63d0\u4f9b\u4e86\u8bb8\u591a\u5728\u7ebf\u5de5\u5177\u4ee5\u5e2e\u52a9\u8bbe\u8ba1\u548c\u751f\u6210\u6e10\u53d8\u4ee3\u7801\uff0c\u5b83\u4eec\u53ef\u4ee5\u4f5c\u4e3a\u9ad8\u6548\u5b9e\u73b0\u8bbe\u8ba1\u7684\u8f85\u52a9\u5de5\u5177\u3002\u6700\u540e\uff0c\u4e0d\u65ad\u5b9e\u9a8c\u548c\u521b\u65b0\u662f\u8bbe\u8ba1\u4f18\u79c0\u6e10\u53d8\u7684\u5173\u952e\uff0c\u4e0d\u8981\u5bb3\u6015\u5c1d\u8bd5\u65b0\u7684\u7ec4\u5408\u548c\u6a21\u5f0f\uff0c\u5229\u7528CSS\u7684\u5f3a\u5927\u529f\u80fd\u6765\u521b\u9020\u51fa\u72ec\u4e00\u65e0\u4e8c\u7684\u89c6\u89c9\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u4f7f\u7528CSS\u6e10\u53d8\u80cc\u666f\u7684\u57fa\u672c\u8bed\u6cd5\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\n\u6e10\u53d8\u80cc\u666f\u53ef\u4ee5\u901a\u8fc7CSS\u7684<code>background<\/code>\u5c5e\u6027\u4e0e<code>linear-gradient()<\/code>\u51fd\u6570\u5b9e\u73b0\u3002\u4f7f\u7528\u8fd9\u4e2a\u51fd\u6570\u53ef\u4ee5\u6307\u5b9a\u6e10\u53d8\u7684\u65b9\u5411\u548c\u989c\u8272\u7b49\u5c5e\u6027\u3002\u4f8b\u5982\uff0c<code>background: linear-gradient(to right, red, blue);<\/code>\u4ee3\u8868\u4ece\u5de6\u5230\u53f3\u6e10\u53d8\u53d8\u5316\u7684\u80cc\u666f\u8272\uff0c\u4ece\u7ea2\u8272\u6e10\u53d8\u5230\u84dd\u8272\u3002<\/p>\n<p><strong>2. \u5982\u4f55\u63a7\u5236\u6e10\u53d8\u80cc\u666f\u7684\u65b9\u5411\u548c\u89d2\u5ea6\uff1f<\/strong><br \/>\n\u4f7f\u7528CSS\u7684<code>background<\/code>\u5c5e\u6027\u7684\u53c2\u6570\u4e2d\u7684<code>to<\/code>\u5173\u952e\u5b57\u6765\u63a7\u5236\u6e10\u53d8\u7684\u65b9\u5411\u3002\u4f8b\u5982\uff0c<code>to top<\/code>\u8868\u793a\u4ece\u4e0b\u5230\u4e0a\u7684\u6e10\u53d8\uff0c<code>to bottom right<\/code>\u8868\u793a\u4ece\u5de6\u4e0a\u5230\u53f3\u4e0b\u7684\u6e10\u53d8\u3002\u9664\u4e86<code>to<\/code>\u5173\u952e\u5b57\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528\u5177\u4f53\u7684\u89d2\u5ea6\u503c\u6765\u6307\u5b9a\u6e10\u53d8\u7684\u65b9\u5411\uff0c\u4f8b\u5982<code>45deg<\/code>\u8868\u793a\u4ece\u5de6\u4e0a\u5230\u53f3\u4e0b\u7684\u6e10\u53d8\u3002<\/p>\n<p><strong>3. \u5982\u4f55\u521b\u5efa\u591a\u6bb5\u5f0f\u7684\u6e10\u53d8\u80cc\u666f\uff1f<\/strong><br \/>\n\u591a\u6bb5\u5f0f\u7684\u6e10\u53d8\u80cc\u666f\u6307\u7684\u662f\u53ef\u4ee5\u5728\u540c\u4e00\u4e2a\u5143\u7d20\u4e2d\u521b\u5efa\u591a\u4e2a\u6e10\u53d8\u3002\u53ef\u4ee5\u4f7f\u7528\u591a\u4e2a<code>color-stop<\/code>\u6765\u63a7\u5236\u6bcf\u4e00\u6bb5\u6e10\u53d8\u7684\u989c\u8272\u4e0e\u4f4d\u7f6e\u3002\u4f8b\u5982\uff0c<code>background: linear-gradient(red, yellow 50%, green);<\/code>\u8868\u793a\u6e10\u53d8\u4ece\u7ea2\u8272\u5230\u9ec4\u8272\uff0c\u7136\u540e\u518d\u6e10\u53d8\u5230\u7eff\u8272\uff0c\u9ec4\u8272\u7684\u4f4d\u7f6e\u572850%\u5904\u3002<\/p>\n<p>\u8bf7\u6ce8\u610f\uff0c\u4e3a\u4e86\u517c\u5bb9\u6027\u8003\u8651\uff0c\u5efa\u8bae\u5728<code>background<\/code>\u5c5e\u6027\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u5907\u9009\u7684\u7eaf\u8272\u80cc\u666f\u4f5c\u4e3afallback\uff0c\u4ee5\u9632\u6e10\u53d8\u80cc\u666f\u4e0d\u88ab\u652f\u6301\u7684\u6d4f\u89c8\u5668\u663e\u793a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u6e10\u53d8\u80cc\u666f\u662f\u7f51\u9875\u8bbe\u8ba1\u4e2d\u4e00\u4e2a\u6d41\u884c\u7684\u89c6\u89c9\u5143\u7d20\uff0c\u4f7f\u7528CSS\u521b\u5efa\u6e10\u53d8\u80cc\u666f\u7684\u65b9\u6cd5\u4e3b\u8981\u6709\u4e24\u79cd\uff1a\u7ebf\u6027\u6e10\u53d8\uff08linear-gra [&hellip;]","protected":false},"author":3,"featured_media":88799,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/88798"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=88798"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/88798\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/88799"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=88798"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=88798"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=88798"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}