{"id":10889,"date":"2023-06-18T14:51:29","date_gmt":"2023-06-18T06:51:29","guid":{"rendered":"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10889"},"modified":"2023-06-18T14:51:29","modified_gmt":"2023-06-18T06:51:29","slug":"css-text-number-loading","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2023\/06\/css-text-number-loading\/","title":{"rendered":"\u6211\u4f7f\u7528CSS\u6a21\u62df\u4e2a\u5047\u7684\u6570\u5b57loading\u6548\u679c"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10889\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=10889<\/a> \u946b\u7a7a\u95f4-\u946b\u751f\u6d3b<br \/>\n\u672c\u6587\u6b22\u8fce\u5206\u4eab\u4e0e\u805a\u5408\uff0c\u5168\u6587\u8f6c\u8f7d\u5c31\u4e0d\u5fc5\u4e86\uff0c\u5c0a\u91cd\u7248\u6743\uff0c\u5708\u5b50\u5c31\u8fd9\u4e48\u5927\uff0c\u82e5\u6025\u7528\u53ef\u4ee5\u8054\u7cfb\u6388\u6743\u3002<\/p>\n<p><script>window.wxShareImgUrl = 'https:\/\/www.zhangxinxu.com\/study\/image\/share\/202306-num-loading.png';<\/script><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202306\/loading-cover.png\" width=\"480\" height=\"299\" alt=\"loading\u793a\u610f\u56fe\" class=\"alignright clip thumb size-medium\" \/><\/p>\n<h3>\u4e00\u3001\u563f\u563f\uff0c\u5148\u770b\u6548\u679c<\/h3>\n<p>\u5982\u4e0b GIF \u5f55\u5c4f\u56fe\u7247\u793a\u610f\uff0c\u70b9\u51fb\u6309\u94ae\uff0c\u5c31\u4f1a\u51fa\u73b0\u767e\u5206\u6bd4\u6570\u5b57\u4e0d\u505c\u9012\u589e\u7684\u753b\u9762\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202306\/number-loading.gif\" width=\"311\" height=\"114\" alt=\"\u5047loading\u6548\u679cGIF\" class=\"alignnone size-medium\" style=\"border:1px solid #eee;\" \/><\/p>\n<p>\u6ce8\u610f\uff0c\u8fd9\u4e2a\u4e0d\u662f\u771fLoading\uff0c\u800c\u662f\u7eafCSS\u6a21\u62df\u7684\u5047loading\u3002<\/p>\n<p>\u6700\u8fd1\u505a\u7684\u67d0\u4e2a\u9879\u76ee\u5c31\u7528\u5230\u4e86\u8fd9\u4e2a\u3002<\/p>\n<p>\u56e0\u4e3a\u6709\u4e2a\u4e0d\u77e5\u9053\u4ec0\u4e48\u65f6\u5019\u624d\u77e5\u9053\u7ed3\u679c\u7684\u8f6e\u8be2\u8bf7\u6c42\uff0c\u4e3a\u4e86\u8ba9\u7528\u6237\u8010\u5fc3\u7b49\u5f85\uff0c\u6709\u5fc5\u8981\u641e\u4e2a\u5047\u8fdb\u5ea6\uff0c\u76f8\u6bd4\u5355\u7eaf\u7684\u8f6c\u8f6c\u8f6c\uff0c\u663e\u7136\u4f53\u9a8c\u8981\u66f4\u597d\u3002<\/p>\n<p>\u4e0d\u8fc7\uff0c\u6a21\u62df\u6570\u5b57loading\u8fd8\u662f\u9700\u8981\u70b9CSS\u529f\u529b\u7684\u3002<\/p>\n<p>\u4e3a\u4e86\u65b9\u4fbf\u5927\u5bb6\u5b66\u4e60\uff0c\u6211\u4eec\u4e0d\u59a8\u5148\u4ece\u7b80\u5355\u7684\u5b9e\u73b0\u5f00\u59cb\u4ecb\u7ecd\u3002<\/p>\n<h3>\u4e8c\u3001\u524d\u83dc\uff0c\u5047\u8fdb\u5ea6\u6761loading<\/h3>\n<p>\u6211\u8bb0\u5f97\u6211\u5f88\u591a\u5e74\u524d\uff0c\u6211\u5b9e\u73b0\u8fc7\u5047\u7684\u8fdb\u5ea6\u6761loading\u7684\uff0c\u7ed3\u679cdemo\u548c\u6587\u7ae0\u90fd\u627e\u4e0d\u5230\u4e86\u3002<\/p>\n<p>\u54a6\uff0c\u96be\u9053\u662f\u68a6\u91cc\u5b9e\u73b0\u7684\u5417\uff1f<\/p>\n<p>\u7a0d\u7b49\uff0c\u6211\u7528AI\u7ed8\u5236\u4e2a\u505a\u68a6\u7684\u7f8e\u56fe\u2026\u2026<\/p>\n<p>\u5988\u5440\uff0c\u53d1\u73b0\u63d0\u793a\u8bcd\u4e0d\u80fd\u51fa\u73b0\u5e8a\uff0c\u5426\u5219\u4e0d\u884c\uff0c\u8bd5\u4e86\u51e0\u4e2a\u90fd\u662f\u5982\u6b64\u3002<\/p>\n<blockquote><p>\u8fd9\u662f\u4e00\u4e2a\u5355\u4eba\u623f\u95f4\uff0c\u5149\u7ebf\u4e0d\u4eae\u4e5f\u4e0d\u6697\uff0c\u623f\u95f4\u6709\u4e00\u4e2a\u4eba\uff0c\u6c89\u7761\uff0c\u8eab\u4e0a\u76d6\u7740\u6bef\u5b50\uff0c\u6b63\u5728\u505a\u7f8e\u68a6\uff0c\u9700\u8981\u4f53\u73b0\u68a6\u5883\u5185\u5bb9\uff0c\u753b\u8d28\u6e05\u6670\uff0c\u52a8\u6f2b\u98ce\u683c\u3002<\/p><\/blockquote>\n<p>\u5413\u6b7b\u4eba\u7684\u6548\u679c\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202306\/2023-06-16_224227.jpg\" width=\"249\" height=\"250\" alt=\"\u7f8e\u68a6AI\u7cdf\u7cd5\u6548\u679c\" class=\"alignnone size-medium\" \/><\/p>\n<blockquote><p>\u8fd9\u662f\u4e00\u4e2a\u5355\u4eba\u623f\u95f4\uff0c\u5149\u7ebf\u4e0d\u4eae\u4e5f\u4e0d\u6697\uff0c\u623f\u95f4\u6709\u4e00\u4e2a\u5e05\u54e5\uff0c\u8eba\u7740\uff0c\u6c89\u7761\uff0c\u8eab\u4e0a\u76d6\u7740\u6bef\u5b50\uff0c\u8111\u95e8\u4e0a\u6709\u6c14\u6ce1\uff0c\u6c14\u6ce1\u4e2d\u51fa\u73b0\u4e86\u7f8e\u4e3d\u7684\u5973\u5b50\uff0c\u770b\u6765\u505a\u4e86\u4e2a\u7f8e\u68a6\uff0c\u4e00\u5b9a\u8981\u4f53\u73b0\u68a6\u5883\u5185\u5bb9\uff0c\u753b\u8d28\u6e05\u6670\uff0c\u52a8\u6f2b\u98ce\u683c\u3002<\/p><\/blockquote>\n<p>\u667a\u969c\u822c\u7684\u6548\u679c\u4ee5\u53ca\u6b8b\u75be\u4eba\u6548\u679c\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202306\/2023-06-16_224513.jpg\" width=\"249\" height=\"250\" alt=\"\u667a\u969cAI\u7ed8\u56fe\u6548\u679c\" class=\"alignnone size-medium\" \/> <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202306\/2023-06-16_225057.jpg\" width=\"450\" height=\"250\" alt=\"\u6b8b\u75be\u4eba\u6548\u679c\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u7b97\u4e86\uff0c\u4e0d\u73a9\u4e86\uff0c\u6d6a\u8d39\u65f6\u95f4\u3002<\/p>\n<p>\u603b\u4e4b\uff0c\u5047loading\u7684\u5b9e\u73b0\u8981\u70b9\u5c31\u662f\uff0c\u52a8\u753b\u6574\u4e2a\u8fdb\u5ea6\u65f6\u95f4\u957f\uff0c\u5148\u5feb\u540e\u6162\uff0c\u7136\u540e\u5c31\u60f3\u662f\u62fc\u591a\u591a\u7684\u780d\u4e00\u5200\uff0c\u6700\u591a99.99%\uff0c\u6c38\u8fdc\u4e0d\u4f1a100%\u3002<\/p>\n<h4>\u5148\u5feb\u540e\u6162<\/h4>\n<p>\u5148\u5feb\u540e\u6162\u7684\u901f\u7387\uff0c\u53ef\u4ee5\u53bb\u8fd9\u4e2a<a href=\"https:\/\/cubic-bezier.com\/\" rel=\"noopener\" target=\"_blank\">\u8d1d\u585e\u5c14\u66f2\u7ebf\u5de5\u5177\u7f51\u7ad9<\/a>\u62d6\u52a8\u6761\u5b50\u786e\u5b9a\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202306\/2023-06-16_225547.png\" width=\"341\" height=\"206\" alt=\"\u66f2\u7ebf\u901f\u7387\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u4e8e\u662f\uff0c\u8981\u5b9e\u73b0\u4e00\u4e2a\u5047loading bar\u5c31\u7b80\u5355\u4e86\uff0c\u5982\u4e0bHTML\u548cCSS\u4ee3\u7801\u793a\u610f\u3002<\/p>\n<pre>\u52a0\u8f7d\u8fdb\u5ea6\uff1a &lt;div class=\"progress\"&gt;&lt;\/div&gt;<\/pre>\n<pre>.progress {\r\n    height: 12px; width: 300px;\r\n    background-color: #f0f2f3;\r\n}\r\n.progress::before {\r\n    content: '';\r\n    display: block;\r\n    width: 0;\r\n    height: 100%;\r\n    background-color: #2486ff;\r\n}\r\n.progress.active::before {\r\n    transition: 100s width cubic-bezier(.08,.81,.29,.99);\r\n    width: 99.9%;    \r\n}<\/pre>\n<p>\u6b64\u65f6\uff0c\u53ea\u9700\u8981\u4e2a\u5bf9\u5e94\u7684 <code>.progress<\/code> \u5143\u7d20\u589e\u52a0\u4e2a\u7c7b\u540d <code>active<\/code>\uff0c\u8fdb\u5ea6\u6761\u5c31\u4f1a\u4e0d\u505c\u5730\u201c\u6316\u554a\u6316\u201d~<\/p>\n<h4>\u773c\u89c1\u4e3a\u5b9e<\/h4>\n<p>\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/202306\/css-progress-bar-loading-demo.php\" rel=\"noopener\" target=\"_blank\">CSS\u5047\u7684\u8fdb\u5ea6\u6761loading\u6548\u679cdemo<\/a><\/p>\n<p>\u70b9\u51fb\u6f14\u793a\u9875\u9762\u4e2d\u7684\u6309\u94ae\uff0c\u5c31\u53ef\u4ee5\u770b\u5230\u8fdb\u5ea6\u6761\u7684\u52a0\u8f7d\u6548\u679c\u4e86\uff0c\u6301\u7eed1\u5206\u534a\u949f\uff0c\u524d\u9762\u5f88\u5feb\uff0c\u540e\u9762\u5c31\u6162\u5982\u4fbf\u79d8\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202306\/2023-06-16_230356.png\" width=\"388\" height=\"189\" alt=\"\u52a0\u8f7d\u793a\u610f\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u7136\u800c\uff0c\u7eaf\u7cb9\u7684\u6761\u5f62\u53d8\u5316\uff0c\u800c\u6ca1\u6709\u767e\u5206\u6bd4\u6570\u5b57\u7684\u5b9e\u65f6\u53d8\u5316\uff0c\u603b\u89c9\u5f97\u5dee\u4e86\u70b9\u5473\u9053\u3002<\/p>\n<p>\u4e0d\u6025\uff0c\u4e0b\u9762\u4e0a\u6b63\u83dc\uff0c\u5047\u7684\u6570\u5b57\u53d8\u5316loading\u6548\u679c\u3002<\/p>\n<h3>\u4e09\u3001\u6b63\u83dc\uff0c\u6570\u5b57\u52a0\u8f7d\u5b9e\u73b0<\/h3>\n<p>\u60f3\u8981\u4f7f\u7528CSS\u6a21\u62df\u6570\u5b57\u53d8\u5316\uff0c\u8fd8\u662f\u9700\u8981\u70b9CSS\u79ef\u7d2f\u7684\u3002<\/p>\n<p>\u9996\u5148\uff0c\u4f7f\u7528CSS\u663e\u793a\u52a8\u6001\u5185\u5bb9\uff0c\u53ea\u80fd\u662f\u4f7f\u7528 <code>content<\/code> \u5c5e\u6027\uff0c\u800c <code>content<\/code> \u5c5e\u6027\u663e\u793a\u53d8\u91cf\u5185\u5bb9\uff0c\u53ea\u80fd\u4f7f\u7528CSS\u8ba1\u6570\u5668\uff0c\u8be6\u89c1 <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2019\/05\/content-css-var\/\">\u5982\u4f55\u501f\u52a9content\u5c5e\u6027\u663e\u793aCSS var\u53d8\u91cf\u503c<\/a> \u4e00\u6587\u3002<\/p>\n<p>\u7531\u4e8e\u6570\u5b57\u4ece0-99\u7684\u53d8\u5316\uff0c\u5b8c\u5168\u6ca1\u6709JS\u53c2\u4e0e\uff0c\u56e0\u6b64\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06CSS\u53d8\u91cf\u5b9a\u4e49\u4e3a\u53ef\u8fc7\u6e21\u5c5e\u6027\uff0c\u8fd9\u6837\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528 transition \u5c5e\u6027\uff0c\u6307\u5b9a\u9996\u5c3e\u548c\u65f6\u95f4\uff0c\u6d4f\u89c8\u5668\u4f1a\u81ea\u52a8\u5b8c\u6210\u6570\u503c\u7684\u53d8\u5316\u3002<\/p>\n<p>\u8fd9\u4e2a\u9700\u8981\u7528\u5230 CSS Houdini \u7684\u77e5\u8bc6\uff0c\u4f7f\u7528<code>@property<\/code>\u89c4\u5219\uff0c\u5bf9CSS\u53d8\u91cf\u8fdb\u884c\u91cd\u65b0\u7684\u81ea\u5b9a\u4e49\u3002<\/p>\n<p>\u4e8e\u662f\uff0cHTML\u4e0d\u53d8\uff08\u548c\u4e0a\u9762\u7684demo\u6848\u4f8b\u4e00\u81f4\uff09\uff0c\u6211\u4eec\u7684CSS\u53ea\u9700\u8981\u5982\u6b64\u6539\u9020\uff0c\u5c31\u53ef\u4ee5\u5b9e\u73b0\u672c\u6587\u4e00\u5f00\u59cb\u7684\u90a3\u4e2aGIF\u5f55\u5c4f\u6548\u679c\u4e86\u3002<\/p>\n<pre>@property --percent { \r\n    syntax: '&lt;integer&gt;';\r\n    inherits: false;\r\n    initial-value: 0;\r\n}\r\n.progress {\r\n    width: 300px;\r\n    line-height: 20px;\r\n    background-color: #f0f2f3;\r\n}\r\n.progress::before {\r\n    --percent: 0;\r\n    counter-reset: progress var(--percent);\r\n    content: counter(progress) '%\\2002';\r\n    display: block;\r\n    width: calc(300px * var(--percent) \/ 100);\r\n    font-size: 12px;\r\n    color: #fff;\r\n    background-color: #2486ff;\r\n    text-align: right;\r\n    white-space: nowrap;\r\n    overflow: hidden;\r\n    transition: none;\r\n}\r\n.progress.active::before {\r\n    --percent: 99;\r\n    transition: 100s --percent cubic-bezier(.08,.81,.29,.99);    \r\n}<\/pre>\n<p>\u773c\u89c1\u4e3a\u5b9e\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/202306\/css-progress-percent-number-loading-demo.php\" rel=\"noopener\" target=\"_blank\">CSS\u5b9e\u73b0\u5e26\u767e\u5206\u6bd4\u6570\u5b57\u7684\u5047loading\u6548\u679cdemo<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202306\/number-loading.gif\" width=\"311\" height=\"114\" alt=\"\u5047loading\u6548\u679cGIF\" class=\"alignnone size-medium\" style=\"border:1px solid #eee;\" \/><\/p>\n<p>\u6b64\u6280\u672f\u76ee\u524dChrome\u548cSafari\u6d4f\u89c8\u5668\u5747\u652f\u6301\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202306\/2023-06-16_234426.png\" width=\"653\" height=\"226\" alt=\"@property\u89c4\u5219\u7684\u517c\u5bb9\u6027\" class=\"alignnone size-medium\" \/><\/p>\n<h4>\u7eaf\u6570\u503c\u52a0\u8f7d<\/h4>\n<p>\u8003\u8651\u5230\u5b9e\u9645\u5f00\u53d1\uff0c\u5f88\u591a\u65f6\u5019\u662f\u4e0d\u4f1a\u4f7f\u7528\u8fdb\u5ea6\u6761\uff0c\u800c\u662f\u7eaf\u6570\u5b57\u53d8\u5316\uff08\u56e0\u4e3a\u5e03\u5c40\u66f4\u7b80\u5355\u66f4\u7075\u6d3b\uff09\uff0c\u6240\u4ee5\u8fd9\u91cc\u9644\u4e0a\u7eaf\u6570\u5b57\u53d8\u5316\u5047loading\u7684\u5b9e\u73b0\u3002<\/p>\n<p>HTML\u7ed3\u6784\u5185\u5bb9\uff1a<\/p>\n<pre>&lt;span class=\"loading-span\"&gt;\u52a0\u8f7d\u4e2d...&lt;output class=\"loading-num\"&gt;&lt;\/output&gt;%&lt;\/span&gt;<\/pre>\n<p>CSS\u7f16\u7801\u7ec6\u8282\uff1a<\/p>\n<pre>@property --percent { \r\n  syntax: '&lt;integer&gt;';\r\n  inherits: false;\r\n  initial-value: 0;\r\n}\r\n.loading-span {\r\n  color: gray;\r\n}\r\n.loading-num::after {\r\n  --percent: 0;\r\n  counter-reset: progress var(--percent);\r\n  content: counter(progress);\r\n  transition: none;\r\n}\r\n.loading-num.running::after {\r\n  --percent: 99;\r\n  transition: 100s --percent cubic-bezier(.08,.81,.29,.99);\r\n}<\/pre>\n<p>JS\u64cd\u5f04\u8fc7\u7a0b\u793a\u610f\uff1a<\/p>\n<pre>button.onclick = function () {\r\n  const eleOutput = document.querySelector('.loading-num');\r\n  if (eleOutput) {\r\n    eleOutput.classList.remove('running');\r\n    this.closest('div').offsetWidth;\r\n    eleOutput.classList.add('running');\r\n  }\r\n};<\/pre>\n<p><strong>\u5b9e\u65f6\u6548\u679c\u5982\u4e0b<\/strong>\uff0c\u70b9\u51fb\u4e0b\u65b9\u6309\u94ae\uff0c\u53ef\u4ee5\u770b\u5230\u6570\u503c\u53d8\u5316\uff0cJS\u53ea\u8d1f\u8d23\u542f\u52a8\uff0c\u53d8\u5316\u8fc7\u7a0b\u5168\u7a0bCSS\u5b8c\u6210\u3002<\/p>\n<div style=\"max-width:360px; padding: 16px;border:1px solid #ddd;height:150px;display:grid;place-items:center;position:relative;font-size:14px;\">\n<button id=\"btnRun\" style=\"position:absolute;left: 16px;top:16px;\">\u5f00\u542floading<\/button><span class=\"loading-span\">\u52a0\u8f7d\u4e2d&#8230;<output class=\"loading-num\"><\/output>%<\/span>\n<\/div>\n<style>@property --percent {  syntax: '<integer>';  inherits: false;  initial-value: 0;}.loading-span {  color: gray;}.loading-num::after {  --percent: 0;  counter-reset: progress var(--percent);  content: counter(progress);transition: none;}.loading-num.running:after {  --percent: 99;  transition: 100s --percent cubic-bezier(.08,.81,.29,.99);}<\/style>\n<p><script>btnRun.onclick = function () {  var eleOutput = document.querySelector('.loading-num');  if (eleOutput) {    eleOutput.classList.remove('running');    this.closest('div').offsetWidth;    eleOutput.classList.add('running');  }};<\/script><\/p>\n<p><strong style=\"color:gray;\">Tips\uff1a<\/strong ><br \/>\n\u6211\u5728\u5b9e\u9645\u5f00\u53d1\u7684\u65f6\u5019\uff0c\u4e60\u60ef\u5728<code>&lt;output&gt;<\/code>\u5143\u7d20\u4e2d\u8bbe\u7f6e\u4e2a 0 \u5360\u4f4d\uff0c\u8bed\u4e49\u3001\u65e0\u969c\u788d\u8bbf\u95ee\u3001\u53ef\u8bfb\u6027\u7b49\u90fd\u6709\u5e2e\u52a9\u3002<br \/>\n\u6b64\u65f6\uff0c\u8fd8\u9700\u8981\u518d\u989d\u5916\u8865\u5145\u4e0b\u9762\u4e24\u6bb5CSS\u8bed\u53e5\uff1a<\/p>\n<pre>.loading-num {\r\n  display: inline-block;\r\n}\r\n.loading-num::first-letter {\r\n  font-size: 0;\r\n}<\/pre>\n<h4>\u66f4\u591a\u5e94\u7528<\/h4>\n<p>\u6570\u5b57\u81ea\u52a8\u53d8\u5316\u8fd8\u6709\u4e00\u4e2a\u7ecf\u5178\u5e94\u7528\u5c31\u662f\u5012\u8ba1\u65f6\uff08\u6216\u8ba1\u65f6\uff09\u6548\u679c\uff0c\u8fd9\u91cc\u6709\u7bc7\u975e\u5e38\u4e0d\u9519\u7684\u6587\u7ae0\uff0c\u6765\u81ea \u524d\u7aef\u4fa6\u63a2 \u516c\u4f17\u53f7\u7684 \u201c<a href=\"https:\/\/mp.weixin.qq.com\/s\/CZQLEDUXktlpdUFRQzj79w\" rel=\"noopener\" target=\"_blank\">\u7eaf CSS \u5b9e\u73b0\u4e00\u4e2a\u8ba1\u65f6\u5668<\/a>\u201d\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202306\/2023-06-18_115437.png\" width=\"322\" height=\"101\" alt=\"\u524d\u7aef\u4fa6\u63a2\u516c\u4f17\u53f7\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u53ef\u4ee5\u4e0d\u501f\u52a9\u4efb\u4f55JS\uff0c\u5b9e\u73b0\u5982\u4e0bGIF\u6240\u793a\u7684\u8ba1\u65f6\u5668\u6548\u679c\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202306\/clock-down-s.gif\" width=\"368\" height=\"197\" alt=\"\u8ba1\u65f6\u5668\u6548\u679c\" class=\"alignnone size-medium\" \/><\/p>\n<h3>\u56db\u3001\u6536\u76d8\u64e6\u5634\u5012\u6e7f\u5783\u573e<\/h3>\n<p>OK\uff0c\u81f3\u6b64\uff0c\u83dc\u90fd\u4e0a\u5b8c\u4e86\u3002<\/p>\n<p>\u518d\u968f\u4fbf\u626f\u626f\u6de1\u5427\uff0c\u5f88\u591a\u4eba\u6700\u559c\u6b22\u8fd9\u4e2a\u73af\u8282\u4e86\u3002<\/p>\n<p>\u8fd9\u91cc\u804a\u4e0b\u975e\u5e38\u7528\u6280\u672f\u5b66\u4e60\u7684\u5fc5\u8981\u6027\uff0c\u672c\u6587\u7684\u4f8b\u5b50\u5f88\u6709\u53c2\u8003\u6027\u3002<\/p>\n<p>\u5047loading\u6211\u5f88\u591a\u5e74\u524d\u5c31\u73a9\u8fc7\uff0c\u4f46\u90fd\u662f\u5f53\u4f5c\u73a9\u5177\uff0c\u6ca1\u60f3\u5230\u6700\u8fd1\u8fd8\u771f\u7684\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u5e94\u7528\uff0c\u5e76\u4e14\u8282\u7ea6\u4e86\u5f88\u591a\u5f00\u53d1\u6210\u672c\uff0c\u6700\u91cd\u8981\u7684\u662f\u8ba9\u9875\u9762\u4e2d\u7684\u903b\u8f91\u53d8\u5f97\u975e\u5e38\u5e72\u51c0\uff0c\u8fd9\u79cd\u611f\u89c9\u7279\u723d\u3002<\/p>\n<p>\u6570\u503c\u53d8\u5316\u5219\u662fCSS\u65b0\u7279\u6027\u77e5\u8bc6\uff0c\u8fd9\u4e2a\u6211\u4e4b\u524d\u4e5f\u4ecb\u7ecd\u8fc7\uff0c\u5982\u4f55\u8ba9\u6e10\u53d8\u53ef\u4ee5\u52a8\u753b\u5316\uff0c\u4e5f\u662f\u7c7b\u4f3c\u7684\uff0c\u4f7f\u7528 Houdini \u7684 @property \u89c4\u5219\u81ea\u5b9a\u4e49 CSS \u53d8\u91cf\u3002<\/p>\n<p>\u8fd9\u662f\u5e7f\u5ea6\u77e5\u8bc6\uff0c\u4e5f\u662f\u4e0d\u5e38\u7528\u7684\u3002<\/p>\n<p>\u56e0\u6b64\u53ef\u89c1\uff0c\u975e\u5e38\u7528\u6280\u672f\u53d1\u6325\u5176\u5e94\u7528\u4ef7\u503c\uff0c\u5f80\u5f80\u5728\u4e00\u6bb5\u65f6\u95f4\u4e4b\u540e\u3002\u4f46\u662f\uff0c\u5982\u679c\u4f60\u6ca1\u6709\u524d\u671f\u7684\u79ef\u7d2f\uff0c\u5f53\u771f\u6b63\u9047\u5230\u7c7b\u4f3c\u573a\u666f\u7684\u65f6\u5019\uff0c\u4f60\u53ea\u80fd\u4f7f\u7528\u4f20\u7edf\u7684\u4e00\u677f\u4e00\u773c\u7684\u65b9\u6cd5\uff0c\u770b\u8d77\u6765\u529f\u80fd\u4e5f\u5b9e\u73b0\uff0c\u4f46\u662f\u81ea\u5df1\u82b1\u5f97\u65f6\u95f4\u591a\u4e0d\u8bf4\uff0c\u505a\u51fa\u6765\u7684\u54c1\u8d28\u548c\u6548\u679c\u5468\u56f4\u4eba\u4e5f\u90fd\u770b\u5728\u773c\u91cc\uff0c\u533a\u5206\u5ea6\u5c31\u8fd9\u6837\u6162\u6162\u51fa\u6765\u4e86\u3002<\/p>\n<p>\u6709\u4eba\u53ef\u80fd\u4f1a\u8bf4\uff0c\u90a3\u5b66\u7684\u8fd9\u4e9b\u4e1c\u897f\u4e5f\u53ef\u80fd\u6c38\u8fdc\u6ca1\u6709\u4f7f\u7528\u673a\u4f1a\uff0c\u5c82\u4e0d\u662f\u767d\u5b66\u4e86\uff1f<\/p>\n<p>\u5bf9\uff0c\u6ca1\u9519\uff0c\u662f\u5b58\u5728\u6982\u7387\u6709\u4e9b\u6280\u672f\u662f\u6ca1\u673a\u4f1a\u5728\u751f\u4ea7\u73af\u5883\u4f7f\u7528\u7684\uff0c\u4f46\uff0c\u5173\u952e\u662f\uff0c\u4f60\u4e0d\u77e5\u9053\u54ea\u4e9b\u767d\u5b66\uff0c\u54ea\u4e9b\u65e5\u540e\u4f1a\u5927\u653e\u5149\u5f69\uff0c\u6240\u4ee5\uff0c\u4e0d\u80fd\u56e0\u564e\u5e9f\u98df\uff0c\u56e0\u4e3a\u67d0\u4e9b\u4e1c\u897f\u5b66\u4e86\u53ef\u80fd\u6ca1\u7528\uff0c\u5c31\u653e\u5f03\u5b66\u4e60\u3002<\/p>\n<p>\u8fd9\u91cc\u6709\u5fc5\u8981\u62ff\u6211\u81ea\u5df1\u4e3e\u4f8b\u3002<\/p>\n<p>\u6211\u7684\u540c\u4e8b\u5e94\u8be5\u90fd\u77e5\u9053\u6211\u4eca\u5e74\u664b\u5347\u53c8\u6210\u529f\u4e86\uff0c\u76ee\u524d\u5e94\u8be5\u662f\u6574\u4e2a\u516c\u53f8\u6280\u672f\u5411\u7ea7\u522b\u6700\u9ad8\u7684\uff0c\u539f\u56e0\u5c31\u5728\u4e8e\u53bb\u5e74\u5728\u67d0\u4e2a\u516c\u53f8\u6700\u5173\u5207\u7684\u9879\u76ee\u4e0a\u63d0\u4f9b\u4e86\u5b9d\u8d35\u7684\u6280\u672f\u652f\u6301\uff0c\u5728\u6574\u4e2a\u56e2\u961f\u7684\u52aa\u529b\u4e0b\uff0c\u53d6\u5f97\u4e86\u4e0d\u9519\u7684\u6210\u7ee9\u3002<\/p>\n<p>\u800c\u5176\u4e2d\u6240\u5e94\u7528\u5230\u7684\u6280\u672f\uff0c\u6211\u8ddf\u5927\u5bb6\u8bb2\uff0c\u5728\u6211\u4e4b\u524d\u5341\u51e0\u5e74\u7684\u5de5\u4f5c\u7ecf\u5386\u4e2d\uff0c\u4ece\u6ca1\u6709\u4f7f\u7528\u8fc7\uff0c\u5982\u679c\u4e0d\u662f\u6709\u8fd9\u6837\u4e00\u4e2a\u9879\u76ee\uff0c\u4f30\u8ba1\u8fd9\u4e9b\u77e5\u8bc6\uff0c\u53ea\u80fd\u4f5c\u4e3a\u77e5\u8bc6\u5206\u4eab\u8f93\u51fa\u51fa\u53bb\uff08\u6240\u4ee5\uff0c\u6ca1\u6709\u767d\u5b66\u8fd9\u79cd\u8bf4\u6cd5\uff0c\u4f60\u53ef\u4ee5\u5b66\u4f1a\u518d\u5206\u4eab\uff0c\u81ea\u7136\u5c31\u6709\u4ef7\u503c\uff09\u3002<\/p>\n<p>\u8fd9\u5c31\u662f\u5168\u9762\u5b66\u4e60\u7684\u4f5c\u7528\uff0c\u4ed6\u5c31\u50cf\u7ed9\u4f60\u7684\u6574\u4e2a\u804c\u4e1a\u751f\u6daf\u53d1\u5c55\u6253\u57fa\u7840\uff0c\u79ef\u7d2f\u8d8a\u591a\u8d8a\u5e7f\uff0c\u8fd9\u4e2a\u5730\u57fa\u5c31\u8d8a\u624e\u5b9e\uff0c\u8fd9\u6837\uff0c\u4ee5\u540e\uff0c\u673a\u4f1a\u5230\u6765\u7684\u65f6\u5019\uff08\u5bf9\u516c\u53f8\u53d1\u5c55\u975e\u5e38\u8fd9\u6837\u7684\u9879\u76ee\uff09\uff0c\u4f60\u624d\u6709\u673a\u4f1a\u5207\u5165\u8fdb\u53bb\uff0c\u5e76\u8bc1\u660e\u81ea\u5df1\u7684\u4ef7\u503c\uff0c\u804c\u4e1a\u53d1\u5c55\u7684\u9ad8\u5ea6\u4e5f\u4f1a\u66f4\u9ad8\u3002<\/p>\n<p>\u4eba\u6709\u65f6\u5019\u505a\u4e8b\u60c5\uff0c\u4e0d\u80fd\u76ef\u7740\u773c\u524d\u7684\u4e00\u4ea9\u4e09\u5206\u5730\uff0c\u5bf9\u773c\u524d\u5229\u76ca\u7b97\u5f97\u592a\u6e05\u695a\u3002<\/p>\n<p>\u8fd9\u4e16\u754c\u7684\u8fd0\u884c\uff0c\u4e8b\u7269\u7684\u53d1\u5c55\uff0c\u4ed6\u4e0d\u662f\u7ebf\u6027\u7684\uff0c\u5b58\u5728\u5927\u91cf\u7684\u968f\u673a\u7684\u6d8c\u73b0\uff0c\u662f\u5927\u91cf\u6df7\u6c8c\u7684\u65e0\u5e8f\u7684\u4e1c\u897f\u521b\u9020\u51fa\u6765\u7684\u6709\u5e8f\uff0c\u6211\u4eec\u6240\u80fd\u628a\u63e1\u7684\u662f\u5927\u65b9\u5411\uff0c\u662f\u8d8b\u52bf\uff0c\u662f\u51e0\u5343\u5e74\u524d\u4eba\u603b\u7ed3\u7684\u54f2\u5b66\u9053\u7406\uff0c\u4f8b\u5982\u5929\u9053\u916c\u52e4\uff0c\u6307\u7684\u5c31\u662f\u4f60\u8db3\u591f\u52e4\u594b\uff0c\u79ef\u7d2f\u8db3\u591f\u591a\uff0c\u90a3\u4e4b\u540e\u88ab\u7737\u987e\u7684\u6982\u7387\u5c31\u66f4\u9ad8\uff08\u6307\u7684\u662f\u628a\u63e1\u673a\u4f1a\uff0c\u51fa\u8272\u5b8c\u6574\u7684\u6982\u7387\u8d8a\u9ad8\uff09\u3002<\/p>\n<p>\u8fd9\u6709\u70b9\u50cf\u80a1\u5e02\uff0c\u77ed\u671f\u662f\u4e0d\u53ef\u9884\u6d4b\u7684\uff0c\u4f60\u603b\u662f\u770b\u7740\u773c\u524d\u51e0\u5929\u7684\u6da8\u6da8\u8dcc\u8dcc\uff0c\u8ba1\u7b97\u5f97\u5931\uff0c\u672a\u6765\u4e00\u5b9a\u5931\u5f97\u66f4\u591a\u3002<\/p>\n<p>\u5f53\u7136\uff0c\u6700\u7ec8\u7684\u4e00\u5207\u8fd8\u662f\u770b\u6bcf\u4e2a\u4eba\u7684\u8ffd\u6c42\uff0c\u6709\u4eba\u5c31\u559c\u6b22\u5728\u516c\u53f8\u5185\u505a\u4e2a\u5c0f\u89d2\u8272\uff0c\u5b89\u5b89\u7a33\u7a33\u8fc7\u65e5\u5b50\uff0c\u90a3\u5c31\u6309\u7167\u81ea\u5df1\u8282\u594f\u751f\u6d3b\u597d\u4e86\uff0c\u4e5f\u633a\u597d\u3002<\/p>\n<p>\u6700\u6015\u90a3\u79cd\u65e2\u4e0d\u7518\u4e8e\u73b0\u72b6\uff0c\u53c8\u81ea\u89c6\u751a\u9ad8\uff0c\u53c8\u4e0d\u613f\u610f\u505a\u51fa\u6539\u53d8\u7684\uff0c\u4f1a\u8fc7\u5f97\u5f88\u7d2f\u3002<\/p>\n<p>\u597d\uff0c\u5c31\u8fd9\u4e9b\u5427\u3002<\/p>\n<p>\u4e0b\u7bc7\u6587\u7ae0\uff0c\u6211\u4eec\u518d\u626f\u70b9\u5176\u4ed6\u7684\uff0c\u611f\u8c22\u60a8\u9605\u8bfb\u5230\u8fd9\u91cc\uff0c\u884c\u4e3a\u4ed3\u4fc3\uff0c\u9519\u8bef\u5728\u6240\u96be\u514d\uff0c\u6b22\u8fce\u6307\u6b63\uff0c\u4e5f\u6b22\u8fce\u8f6c\u53d1\u6b64\u6587\u3002<\/p>\n<p>???<\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u6b22\u8fce\u5206\u4eab\uff0c\u52ff\u5168\u6587\u8f6c\u8f7d\uff0c\u5982\u679c\u5b9e\u5728\u559c\u6b22\uff0c\u53ef\u6536\u85cf\uff0c\u6c38\u4e0d\u8fc7\u671f\uff0c\u4e14\u4f1a\u53ca\u65f6\u66f4\u65b0\u77e5\u8bc6\u70b9\u53ca\u4fee\u6b63\u9519\u8bef\uff0c\u9605\u8bfb\u4f53\u9a8c\u4e5f\u66f4\u597d\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10889\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=10889<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202306\/loading-cover.png\" width=\"160\" height=\"100\" alt=\"loading\u793a\u610f\u56fe\" class=\"alignright size-medium\" loading=\"lazy\" \/><\/p>\n<p>\u6709\u6ca1\u6709\u529e\u6cd5\u4f7f\u7528CSS\u8ba9\u6570\u5b57\u4ece0-100\u50cf\u52a8\u753b\u4e00\u6837\u4e0d\u505c\u53d8\u5316\u5462\uff1f\u5982\u679c\u4f60\u4e00\u65f6\u4e0d\u77e5\u9053\u8be5\u5982\u4f55\u5b9e\u73b0\uff0c\u5219\u672c\u6587\u503c\u5f97\u4e00\u770b\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":[1926,938,1506,860,1369,1008,780,288],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10889"}],"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=10889"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10889\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=10889"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=10889"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=10889"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}