{"id":1273,"date":"2024-11-10T16:34:13","date_gmt":"2024-11-10T08:34:13","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1273\/"},"modified":"2024-11-10T16:34:13","modified_gmt":"2024-11-10T08:34:13","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-css-%e5%88%9b%e5%bb%ba%e4%b8%80%e4%b8%aa%e6%b8%90%e5%8f%98%e8%89%b2%e9%bd%bf%e7%8a%b6%e5%9c%86%e7%8e%af%ef%bc%8c%e4%bd%bf%e5%85%b6%e5%b7%a6%e4%b8%8a%e8%a7%92","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1273\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 CSS \u521b\u5efa\u4e00\u4e2a\u6e10\u53d8\u8272\u9f7f\u72b6\u5706\u73af\uff0c\u4f7f\u5176\u5de6\u4e0a\u89d2\u4e3a\u767d\u8272\uff0c \u53f3\u4e0b\u89d2\u5b8c\u5168\u900f\u660e\uff0c \u5e76\u4e14\u53ef\u4ee5\u65cb\u8f6c\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173034940929120.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 CSS \u521b\u5efa\u4e00\u4e2a\u6e10\u53d8\u8272\u9f7f\u72b6\u5706\u73af\uff0c\u4f7f\u5176\u5de6\u4e0a\u89d2\u4e3a\u767d\u8272\uff0c \u53f3\u4e0b\u89d2\u5b8c\u5168\u900f\u660e\uff0c \u5e76\u4e14\u53ef\u4ee5\u65cb\u8f6c\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 CSS \u521b\u5efa\u4e00\u4e2a\u6e10\u53d8\u8272\u9f7f\u72b6\u5706\u73af\uff0c\u4f7f\u5176\u5de6\u4e0a\u89d2\u4e3a\u767d\u8272\uff0c \u53f3\u4e0b\u89d2\u5b8c\u5168\u900f\u660e\uff0c \u5e76\u4e14\u53ef\u4ee5\u65cb\u8f6c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u6e10\u53d8\u8272\u9f7f\u72b6\u5706\u73af\u5b9e\u73b0\u65b9\u6cd5<\/strong><\/p>\n<p>\u5982\u4f55\u5728\u7f51\u9875\u4e2d\u521b\u5efa\u4e00\u4e2a\u9f7f\u72b6\u5706\u73af\uff0c\u5176\u4e2d\u5de6\u4e0a\u89d2\u4e3a\u767d\u8272\uff0c\u5176\u4ed6\u533a\u57df\u767d\u8272\u6e10\u53d8\u900f\u660e\uff0c\u53f3\u4e0b\u89d2\u5b8c\u5168\u900f\u660e\uff0c\u4e14\u5706\u73af\u53ef\u65cb\u8f6c\u800c\u6e10\u53d8\u533a\u57df\u4fdd\u6301\u4e0d\u53d8\uff1f<\/p>\n<p><strong>\u5b9e\u73b0\u65b9\u6cd5\uff1a<\/strong><\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528 transform \u5c5e\u6027\u65cb\u8f6c\u5706\u73af\uff1a<\/strong><\/p>\n<ul>\n<li>\u521b\u5efa\u4e00\u4e2a\u5706\u73af\u5143\u7d20\uff0c\u5e76\u4f7f\u7528 transform \u5c5e\u6027\u5bf9\u5176\u8fdb\u884c\u65cb\u8f6c\u3002<\/li>\n<li>\u8bbe\u7f6e transform-origin \u4e3a \u5706\u73af\u4e2d\u5fc3\uff0c\u4ee5\u786e\u4fdd\u5728\u65cb\u8f6c\u65f6\u5706\u73af\u4fdd\u6301\u5728\u539f\u4f4d\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528 linear-gradient() \u521b\u5efa\u6e10\u53d8\u8272\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ul>\n<li>\u4f7f\u7528 background: linear-gradient() \u5c5e\u6027\u521b\u5efa\u767d\u8272\u5230\u900f\u660e\u7684\u6e10\u53d8\u8272\uff0c\u6307\u5b9a\u6e10\u53d8\u89d2\u5ea6\u4e3a 135 \u5ea6\u3002<\/li>\n<li>\u5c06\u6e10\u53d8\u8272\u5e94\u7528\u4e8e\u5706\u73af\u5143\u7d20\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528 mask \u906e\u7f69\u521b\u5efa\u53f3\u4e0b\u89d2\u900f\u660e\u533a\u57df\uff1a<\/strong><\/p>\n<ul>\n<li>\u521b\u5efa\u4e00\u4e2a\u8986\u76d6\u53f3\u4e0b\u89d2\u533a\u57df\u7684\u77e9\u5f62\u5143\u7d20\u3002<\/li>\n<li>\u4f7f\u7528 mask \u5c5e\u6027\u5c06\u77e9\u5f62\u5143\u7d20\u4f5c\u4e3a\u906e\u7f69\uff0c\u5728\u5706\u73af\u5143\u7d20\u4e0a\u521b\u5efa\u4e0d\u900f\u660e\u533a\u57df\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528 animation \u52a8\u753b\u5b9e\u73b0\u65cb\u8f6c\uff1a<\/strong><\/p>\n<ul>\n<li>\u521b\u5efa\u4e00\u4e2a @keyframes \u52a8\u753b\u89c4\u5219\uff0c\u5b9a\u4e49\u5706\u73af\u7684\u65cb\u8f6c\u52a8\u753b\u3002<\/li>\n<li>\u5c06\u52a8\u753b\u89c4\u5219\u5e94\u7528\u4e8e\u5706\u73af\u5143\u7d20\uff0c\u4f7f\u5176\u81ea\u52a8\u65cb\u8f6c\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><strong>\u5b8c\u6574\u4ee3\u7801\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>&lt;div id=\"ring\"&gt;\n&lt;\/div&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>#ring {\n  width: 200px;\n  height: 200px;\n  border: 1px solid black;\n  border-radius: 50%;\n  background: linear-gradient(135deg, white 0%, transparent 135deg);\n  transform-origin: center;\n  animation: rotate 5s infinite linear;\n}\n\n@keyframes rotate {\n  from {\n    transform: rotate(0deg);\n  }\n  to {\n    transform: rotate(360deg);\n  }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u9605\u8bfb\u66f4\u591a\uff1a<\/strong><\/p>\n<ul>\n<li>[linear-gradient() &#8211; CSS | MDN](https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/linear-gradient)<\/li>\n<li>[transform &#8211; CSS | MDN](https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/transform)<\/li>\n<li>[animation &#8211; CSS | MDN](https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/animation)<\/li>\n<li>[@keyframes &#8211; CSS | MDN](https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/@keyframes)<\/li>\n<li>[mask &#8211; CSS | MDN](https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/mask)<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 CSS \u521b\u5efa\u4e00\u4e2a\u6e10\u53d8\u8272\u9f7f\u72b6\u5706\u73af\uff0c\u4f7f\u5176\u5de6\u4e0a\u89d2\u4e3a\u767d\u8272\uff0c \u53f3\u4e0b\u89d2\u5b8c\u5168\u900f\u660e\uff0c \u5e76\u4e14\u53ef\u4ee5\u65cb\u8f6c\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6e10\u53d8\u8272\u9f7f\u72b6\u5706\u73af\u5b9e\u73b0\u65b9\u6cd5 \u5982\u4f55\u5728\u7f51\u9875\u4e2d\u521b\u5efa\u4e00\u4e2a\u9f7f\u72b6\u5706\u73af\uff0c\u5176\u4e2d\u5de6\u4e0a\u89d2\u4e3a\u767d\u8272\uff0c\u5176\u4ed6\u533a\u57df\u767d\u8272\u6e10\u53d8\u900f\u660e\uff0c\u53f3\u4e0b\u89d2\u5b8c\u5168\u900f\u660e\uff0c\u4e14\u5706\u73af\u53ef\u65cb\u8f6c\u800c\u6e10\u53d8\u533a\u57df\u4fdd\u6301\u4e0d\u53d8\uff1f \u5b9e\u73b0\u65b9\u6cd5\uff1a \u4f7f\u7528 transform \u5c5e\u6027\u65cb\u8f6c\u5706\u73af\uff1a \u521b\u5efa\u4e00\u4e2a\u5706\u73af\u5143\u7d20\uff0c\u5e76\u4f7f\u7528 transform \u5c5e\u6027\u5bf9\u5176\u8fdb\u884c\u65cb\u8f6c\u3002 \u8bbe\u7f6e transform-origin \u4e3a \u5706\u73af\u4e2d\u5fc3\uff0c\u4ee5\u786e\u4fdd\u5728\u65cb\u8f6c\u65f6\u5706\u73af\u4fdd\u6301\u5728\u539f\u4f4d\u3002 \u4f7f\u7528 linear-gradient() \u521b\u5efa\u6e10\u53d8\u8272\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4f7f\u7528 background: linear-gradient() \u5c5e\u6027\u521b\u5efa\u767d\u8272\u5230\u900f\u660e\u7684\u6e10\u53d8\u8272\uff0c\u6307\u5b9a\u6e10\u53d8\u89d2\u5ea6\u4e3a 135 \u5ea6\u3002 \u5c06\u6e10\u53d8\u8272\u5e94\u7528\u4e8e\u5706\u73af\u5143\u7d20\u3002 \u4f7f\u7528 mask \u906e\u7f69\u521b\u5efa\u53f3\u4e0b\u89d2\u900f\u660e\u533a\u57df\uff1a \u521b\u5efa\u4e00\u4e2a\u8986\u76d6\u53f3\u4e0b\u89d2\u533a\u57df\u7684\u77e9\u5f62\u5143\u7d20\u3002 \u4f7f\u7528 mask \u5c5e\u6027\u5c06\u77e9\u5f62\u5143\u7d20\u4f5c\u4e3a\u906e\u7f69\uff0c\u5728\u5706\u73af\u5143\u7d20\u4e0a\u521b\u5efa\u4e0d\u900f\u660e\u533a\u57df\u3002 \u4f7f\u7528 animation \u52a8\u753b\u5b9e\u73b0\u65cb\u8f6c\uff1a \u521b\u5efa\u4e00\u4e2a @keyframes \u52a8\u753b\u89c4\u5219\uff0c\u5b9a\u4e49\u5706\u73af\u7684\u65cb\u8f6c\u52a8\u753b\u3002 \u5c06\u52a8\u753b\u89c4\u5219\u5e94\u7528\u4e8e\u5706\u73af\u5143\u7d20\uff0c\u4f7f\u5176\u81ea\u52a8\u65cb\u8f6c\u3002 \u5b8c\u6574\u4ee3\u7801\u793a\u4f8b\uff1a &lt;div id=&#8221;ring&#8221;&gt; &lt;\/div&gt; \u767b\u5f55\u540e\u590d\u5236 #ring { width: 200px; height: 200px; border: 1px solid black; border-radius: 50%; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-1273","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1273","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=1273"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1273\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}