{"id":238393,"date":"2023-12-26T06:51:19","date_gmt":"2023-12-25T22:51:19","guid":{"rendered":"https:\/\/www.idc.net\/help\/238393\/"},"modified":"2023-12-26T06:51:19","modified_gmt":"2023-12-25T22:51:19","slug":"css%e5%85%a5%e9%97%a8-animation-fill-mode%ef%bc%88%e5%8a%a8%e7%94%bb%e5%a1%ab%e5%85%85%e6%a8%a1%e5%bc%8f%ef%bc%89","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/238393\/","title":{"rendered":"Css\u5165\u95e8: animation-fill-mode\uff08\u52a8\u753b\u586b\u5145\u6a21\u5f0f\uff09"},"content":{"rendered":"<p><title id=\"css%e5%85%a5%e9%97%a8-animation-fill-mode%ef%bc%88%e5%8a%a8%e7%94%bb%e5%a1%ab%e5%85%85%e6%a8%a1%e5%bc%8f%ef%bc%89-rsyTfgKfXC\">Css\u5165\u95e8: animation-fill-mode\uff08\u52a8\u753b\u586b\u5145\u6a21\u5f0f\uff09<\/title><\/p>\n<h1 id=\"css%e5%85%a5%e9%97%a8-animation-fill-mode%ef%bc%88%e5%8a%a8%e7%94%bb%e5%a1%ab%e5%85%85%e6%a8%a1%e5%bc%8f%ef%bc%89-rsyTfgKfXC\">Css\u5165\u95e8: animation-fill-mode\uff08\u52a8\u753b\u586b\u5145\u6a21\u5f0f\uff09<\/h1>\n<p>CSS\u52a8\u753b\u662f\u7f51\u9875\u8bbe\u8ba1\u4e2d\u5e38\u7528\u7684\u4e00\u79cd\u6280\u672f\uff0c\u53ef\u4ee5\u4e3a\u7f51\u9875\u6dfb\u52a0\u751f\u52a8\u7684\u6548\u679c\u548c\u4ea4\u4e92\u6027\u3002\u5728CSS\u52a8\u753b\u4e2d\uff0canimation-fill-mode\uff08\u52a8\u753b\u586b\u5145\u6a21\u5f0f\uff09\u662f\u4e00\u4e2a\u91cd\u8981\u7684\u5c5e\u6027\uff0c\u5b83\u51b3\u5b9a\u4e86\u52a8\u753b\u5728\u64ad\u653e\u524d\u548c\u64ad\u653e\u540e\u7684\u72b6\u6001\u3002<\/p>\n<h2 id=\"%e4%bb%80%e4%b9%88%e6%98%afanimation-fill-mode%ef%bc%9f-rsyTfgKfXC\">\u4ec0\u4e48\u662fanimation-fill-mode\uff1f<\/h2>\n<p>animation-fill-mode\u5c5e\u6027\u7528\u4e8e\u6307\u5b9a\u52a8\u753b\u64ad\u653e\u524d\u548c\u64ad\u653e\u540e\u7684\u72b6\u6001\u3002\u5b83\u6709\u56db\u4e2a\u53ef\u80fd\u7684\u503c\uff1a<\/p>\n<ul>\n<li><strong>none\uff1a<\/strong>\u52a8\u753b\u4e0d\u4f1a\u5f71\u54cd\u52a8\u753b\u64ad\u653e\u524d\u548c\u64ad\u653e\u540e\u7684\u72b6\u6001\u3002<\/li>\n<li><strong>forwards\uff1a<\/strong>\u52a8\u753b\u5c06\u4fdd\u6301\u5728\u6700\u540e\u4e00\u5e27\u7684\u72b6\u6001\u3002<\/li>\n<li><strong>backwards\uff1a<\/strong>\u52a8\u753b\u5c06\u5e94\u7528\u7b2c\u4e00\u5e27\u7684\u72b6\u6001\u3002<\/li>\n<li><strong>both\uff1a<\/strong>\u52a8\u753b\u5c06\u540c\u65f6\u5e94\u7528\u7b2c\u4e00\u5e27\u548c\u6700\u540e\u4e00\u5e27\u7684\u72b6\u6001\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8animation-fill-mode%ef%bc%9f-rsyTfgKfXC\">\u5982\u4f55\u4f7f\u7528animation-fill-mode\uff1f<\/h2>\n<p>\u8981\u4f7f\u7528animation-fill-mode\u5c5e\u6027\uff0c\u9996\u5148\u9700\u8981\u5b9a\u4e49\u4e00\u4e2aCSS\u52a8\u753b\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<pre><code>\n@keyframes myAnimation {\n  0% { opacity: 0; }\n  100% { opacity: 1; }\n}\n\n.myElement {\n  animation-name: myAnimation;\n  animation-duration: 2s;\n  animation-fill-mode: forwards;\n}\n<\/code><\/pre>\n<p>\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3amyAnimation\u7684\u52a8\u753b\uff0c\u5b83\u4ece0%\u7684\u900f\u660e\u5ea6\u5230100%\u7684\u900f\u660e\u5ea6\u3002\u7136\u540e\uff0c\u6211\u4eec\u5c06\u8fd9\u4e2a\u52a8\u753b\u5e94\u7528\u5230\u4e00\u4e2a\u7c7b\u540d\u4e3amyElement\u7684\u5143\u7d20\u4e0a\uff0c\u5e76\u8bbe\u7f6eanimation-fill-mode\u4e3aforwards\uff0c\u8fd9\u610f\u5473\u7740\u52a8\u753b\u5c06\u4fdd\u6301\u5728\u6700\u540e\u4e00\u5e27\u7684\u72b6\u6001\u3002<\/p>\n<h2 id=\"animation-fill-mode%e7%9a%84%e5%ba%94%e7%94%a8%e5%9c%ba%e6%99%af-rsyTfgKfXC\">animation-fill-mode\u7684\u5e94\u7528\u573a\u666f<\/h2>\n<p>animation-fill-mode\u5c5e\u6027\u5728\u5f88\u591a\u60c5\u51b5\u4e0b\u90fd\u975e\u5e38\u6709\u7528\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u5e94\u7528\u573a\u666f\uff1a<\/p>\n<h3 id=\"1-%e9%81%bf%e5%85%8d%e9%97%aa%e7%83%81-rsyTfgKfXC\">1. \u907f\u514d\u95ea\u70c1<\/h3>\n<p>\u5f53\u52a8\u753b\u64ad\u653e\u5b8c\u6bd5\u540e\uff0c\u5982\u679c\u6ca1\u6709\u8bbe\u7f6eanimation-fill-mode\u5c5e\u6027\uff0c\u5143\u7d20\u5c06\u7acb\u5373\u8fd4\u56de\u5230\u52a8\u753b\u64ad\u653e\u524d\u7684\u72b6\u6001\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u95ea\u70c1\u7684\u6548\u679c\u3002\u901a\u8fc7\u8bbe\u7f6eanimation-fill-mode\u4e3aforwards\uff0c\u53ef\u4ee5\u907f\u514d\u8fd9\u79cd\u95ea\u70c1\u3002<\/p>\n<h3 id=\"2-%e4%bf%9d%e6%8c%81%e5%8a%a8%e7%94%bb%e7%8a%b6%e6%80%81-rsyTfgKfXC\">2. \u4fdd\u6301\u52a8\u753b\u72b6\u6001<\/h3>\n<p>\u6709\u65f6\u5019\u6211\u4eec\u5e0c\u671b\u52a8\u753b\u64ad\u653e\u5b8c\u6bd5\u540e\u4fdd\u6301\u5728\u6700\u540e\u4e00\u5e27\u7684\u72b6\u6001\uff0c\u4ee5\u4fbf\u7528\u6237\u53ef\u4ee5\u770b\u5230\u52a8\u753b\u7684\u6700\u7ec8\u6548\u679c\u3002\u901a\u8fc7\u8bbe\u7f6eanimation-fill-mode\u4e3aforwards\uff0c\u53ef\u4ee5\u5b9e\u73b0\u8fd9\u4e2a\u6548\u679c\u3002<\/p>\n<h3 id=\"3-%e5%88%9d%e5%a7%8b%e7%8a%b6%e6%80%81%e5%8a%a8%e7%94%bb-rsyTfgKfXC\">3. \u521d\u59cb\u72b6\u6001\u52a8\u753b<\/h3>\n<p>\u6709\u65f6\u5019\u6211\u4eec\u5e0c\u671b\u52a8\u753b\u5728\u9875\u9762\u52a0\u8f7d\u65f6\u5c31\u5f00\u59cb\u64ad\u653e\uff0c\u800c\u4e0d\u662f\u7b49\u5f85\u7528\u6237\u7684\u4ea4\u4e92\u3002\u901a\u8fc7\u8bbe\u7f6eanimation-fill-mode\u4e3abackwards\uff0c\u53ef\u4ee5\u8ba9\u52a8\u753b\u5e94\u7528\u7b2c\u4e00\u5e27\u7684\u72b6\u6001\uff0c\u4ece\u800c\u5b9e\u73b0\u521d\u59cb\u72b6\u6001\u52a8\u753b\u3002<\/p>\n<h2 id=\"%e6%80%bb%e7%bb%93-rsyTfgKfXC\">\u603b\u7ed3<\/h2>\n<p>animation-fill-mode\u662fCSS\u52a8\u753b\u4e2d\u4e00\u4e2a\u91cd\u8981\u7684\u5c5e\u6027\uff0c\u7528\u4e8e\u6307\u5b9a\u52a8\u753b\u64ad\u653e\u524d\u548c\u64ad\u653e\u540e\u7684\u72b6\u6001\u3002\u5b83\u6709\u56db\u4e2a\u53ef\u80fd\u7684\u503c\uff1anone\u3001forwards\u3001backwards\u548cboth\u3002\u901a\u8fc7\u5408\u7406\u4f7f\u7528animation-fill-mode\uff0c\u6211\u4eec\u53ef\u4ee5\u5b9e\u73b0\u66f4\u52a0\u751f\u52a8\u548c\u4ea4\u4e92\u6027\u7684\u7f51\u9875\u8bbe\u8ba1\u3002<\/p>\n<h3 id=\"%e9%a6%99%e6%b8%af%e6%9c%8d%e5%8a%a1%e5%99%a8%e9%a6%96%e9%80%89%e5%90%8e%e6%b5%aa%e4%ba%91-rsyTfgKfXC\">\u9999\u6e2f\u670d\u52a1\u5668\u9996\u9009\u540e\u6d6a\u4e91<\/h3>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5bfb\u627e\u53ef\u9760\u7684\u9999\u6e2f\u670d\u52a1\u5668\u63d0\u4f9b\u5546\uff0c\u540e\u6d6a\u4e91\u662f\u60a8\u7684\u9996\u9009\u3002\u6211\u4eec\u63d0\u4f9b\u9ad8\u6027\u80fd\u7684\u9999\u6e2f\u670d\u52a1\u5668\uff0c\u786e\u4fdd\u60a8\u7684\u7f51\u7ad9\u5728\u9999\u6e2f\u5730\u533a\u7684\u7528\u6237\u80fd\u591f\u5feb\u901f\u8bbf\u95ee\u3002<\/p>\n<p>\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u6211\u4eec\u7684\u9999\u6e2f\u670d\u52a1\u5668\u4ea7\u54c1\uff0c\u8bf7\u8bbf\u95ee\u6211\u4eec\u7684\u5b98\u7f51\uff1a<a href=\"https:\/\/idc.net\">https:\/\/idc.net<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Css\u5165\u95e8: animation-fill-mode\uff08\u52a8\u753b\u586b\u5145\u6a21\u5f0f\uff09 Css\u5165\u95e8: animation-fil [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[197854],"tags":[],"class_list":["post-238393","post","type-post","status-publish","format-standard","hentry","category-html"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/238393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=238393"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/238393\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=238393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=238393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=238393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}