{"id":1815,"date":"2022-10-12T17:51:56","date_gmt":"2022-10-12T09:51:56","guid":{"rendered":"https:\/\/www.tra56.com\/?p=1815"},"modified":"2022-10-12T17:51:56","modified_gmt":"2022-10-12T09:51:56","slug":"1815","status":"publish","type":"post","link":"https:\/\/www.tra56.com\/1815.html","title":{"rendered":"CSS linear-gradient() \u51fd\u6570"},"content":{"rendered":"
\u4ee5\u4e0b\u5b9e\u4f8b\u6f14\u793a\u4e86\u4ece\u5934\u90e8\u5f00\u59cb\u7684\u7ebf\u6027\u6e10\u53d8\uff0c\u4ece\u7ea2\u8272\u5f00\u59cb\uff0c\u8f6c\u4e3a\u9ec4\u8272\uff0c\u518d\u5230\u84dd\u8272:<\/span><\/p>\n linear-gradient() \u51fd\u6570\u7528\u4e8e\u521b\u5efa\u4e00\u4e2a\u8868\u793a\u4e24\u79cd\u6216\u591a\u79cd\u989c\u8272\u7ebf\u6027\u6e10\u53d8\u7684\u56fe\u7247\u3002<\/p>\n \u521b\u5efa\u4e00\u4e2a\u7ebf\u6027\u6e10\u53d8\uff0c\u9700\u8981\u6307\u5b9a\u4e24\u79cd\u989c\u8272\uff0c\u8fd8\u53ef\u4ee5\u5b9e\u73b0\u4e0d\u540c\u65b9\u5411\uff08\u6307\u5b9a\u4e3a\u4e00\u4e2a\u89d2\u5ea6\uff09\u7684\u6e10\u53d8\u6548\u679c\uff0c\u5982\u679c\u4e0d\u6307\u5b9a\u65b9\u5411\uff0c\u9ed8\u8ba4\u4ece\u4e0a\u5230\u4e0b\u6e10\u53d8\u3002<\/p>\n <\/p>\n \u652f\u6301\u7248\u672c\uff1aCSS3<\/p>\n \u8868\u683c\u4e2d\u7684\u6570\u5b57\u8868\u793a\u652f\u6301\u8be5\u51fd\u6570\u7684\u7b2c\u4e00\u4e2a\u6d4f\u89c8\u5668\u7248\u672c\u53f7\u3002<\/p>\n "webkit" \u6216 "moz" \u6216 "o" \u6307\u5b9a\u7684\u6570\u5b57\u4e3a\u652f\u6301\u8be5\u51fd\u6570\u7684\u7b2c\u4e00\u4e2a\u7248\u672c\u53f7\u524d\u7f00\u3002<\/p>\n <\/p>\n \u4ee5\u4e0b\u5b9e\u4f8b\u6f14\u793a\u4e86\u4ece\u5de6\u4fa7\u5f00\u59cb\u7684\u7ebf\u6027\u6e10\u53d8\uff0c\u4ece\u7ea2\u8272\u5f00\u59cb\uff0c\u8f6c\u4e3a\u9ec4\u8272:<\/p>\n \u4ee5\u4e0b\u5b9e\u4f8b\u6f14\u793a\u4e86\u4ece\u5de6\u4e0a\u89d2\u5230\u53f3\u4e0b\u89d2\u7684\u7ebf\u6027\u6e10\u53d8:<\/p>\n \u4ee5\u4e0b\u5b9e\u4f8b\u6f14\u793a\u4e86\u7ebf\u6027\u6e10\u53d8\u6307\u5b9a\u4e00\u4e2a\u89d2\u5ea6:<\/p>\n \u4ee5\u4e0b\u5b9e\u4f8b\u6f14\u793a\u4e86\u591a\u4e2a\u7ec8\u6b62\u8272:<\/p>\n \u4ee5\u4e0b\u5b9e\u4f8b\u4f7f\u7528\u4e86\u900f\u660e\u5ea6:<\/p>\n \u6ce8\u610f\uff1a<\/strong> Internet Explorer 8 \u53ca\u4e4b\u524d\u7684\u7248\u672c\u4e0d\u652f\u6301\u6e10\u53d8\u3002<\/span><\/p>\n","protected":false},"excerpt":{"rendered":" \u4ee5\u4e0b\u5b9e\u4f8b\u6f14\u793a\u4e86\u4ece\u5934\u90e8\u5f00\u59cb\u7684\u7ebf\u6027\u6e10\u53d8\uff0c\u4ece\u7ea2\u8272\u5f00\u59cb\uff0c\u8f6c\u4e3a\u9ec4\u8272\uff0c\u518d\u5230\u84dd\u8272: #grad { & […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3,1,49],"tags":[116,117],"class_list":["post-1815","post","type-post","status-publish","format-standard","hentry","category-css","category-css3","category-html","category-web_html","tag-css","tag-linear-gradient"],"_links":{"self":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/1815"}],"collection":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/comments?post=1815"}],"version-history":[{"count":1,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/1815\/revisions"}],"predecessor-version":[{"id":1816,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/1815\/revisions\/1816"}],"wp:attachment":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/media?parent=1815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/categories?post=1815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/tags?post=1815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}#grad {\r\n background-image: linear-gradient(red, yellow, blue);}<\/pre>\n
\u5b9a\u4e49\u4e0e\u7528\u6cd5<\/h2>\n
\/* \u4ece\u4e0a\u5230\u4e0b\uff0c\u84dd\u8272\u6e10\u53d8\u5230\u7ea2\u8272 *\/linear-gradient(blue, red); \r\n\/* \u6e10\u53d8\u8f74\u4e3a45\u5ea6\uff0c\u4ece\u84dd\u8272\u6e10\u53d8\u5230\u7ea2\u8272 *\/linear-gradient(45deg, blue, red); \r\n\/* \u4ece\u53f3\u4e0b\u5230\u5de6\u4e0a\u3001\u4ece\u84dd\u8272\u6e10\u53d8\u5230\u7ea2\u8272 *\/linear-gradient(to left top, blue, red); \r\n\/* \u4ece\u4e0b\u5230\u4e0a\uff0c\u4ece\u84dd\u8272\u5f00\u59cb\u6e10\u53d8\u3001\u5230\u9ad8\u5ea640%\u4f4d\u7f6e\u662f\u7eff\u8272\u6e10\u53d8\u5f00\u59cb\u3001\u6700\u540e\u4ee5\u7ea2\u8272\u7ed3\u675f *\/linear-gradient(0deg, blue, green 40%, red);<\/pre>\n
\u7ebf\u6027\u6e10\u53d8\u5b9e\u4f8b<\/h3>\n
\n\u6d4f\u89c8\u5668\u652f\u6301<\/h2>\n
CSS \u8bed\u6cd5<\/h2>\n
background-image: linear-gradient(direction, color-stop1, color-stop2, ...);<\/pre>\n
\u503c<\/th>\n \u63cf\u8ff0<\/th>\n<\/tr>\n
\n\u66f4\u591a\u5b9e\u4f8b<\/h2>\n
\u5b9e\u4f8b<\/h2>\n
#grad {\r\n background-image: linear-gradient(to right, red , yellow);}<\/pre>\n
\u5b9e\u4f8b<\/h2>\n
#grad { background-image: linear-gradient(to bottom right, red , yellow);}<\/pre>\n
\u5b9e\u4f8b<\/h2>\n
#grad {\r\n background-image: linear-gradient(180deg, red, yellow);}<\/pre>\n
\u5b9e\u4f8b<\/h2>\n
#grad {\r\n background-image: linear-gradient(to right, red,orange,yellow,green,blue,indigo,violet);}<\/pre>\n
\u5b9e\u4f8b<\/h2>\n
#grad {\r\n background-image: linear-gradient(to right, rgba(255,0,0,0), rgba(255,0,0,1));}<\/pre>\n