{"id":10188,"date":"2021-11-14T22:44:34","date_gmt":"2021-11-14T14:44:34","guid":{"rendered":"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10188"},"modified":"2021-11-23T20:40:22","modified_gmt":"2021-11-23T12:40:22","slug":"html-meter-password","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2021\/11\/html-meter-password\/","title":{"rendered":"\u5bc6\u7801\u5f3a\u5ea6\u6548\u679c\u6700\u4f73\u5b9e\u73b0\u4e00\u5b9a\u662fHTML meter\u5143\u7d20"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10188\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=10188<\/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\/202111-html-meter.png';if(!\/zhangxinxu\/.test(location.host)){document.body.addEventListener('mousedown',function(){location.href='https:\/\/www.zhangxinxu.com\/wordpress\/?p=10188'});}<\/script><\/p>\n<p>\u6ce8\u518c\u65f6\u5019\u5bc6\u7801\u8f93\u5165\u6846\u663e\u793a\u5bc6\u7801\u5f3a\u5ea6\u662f\u4e2a\u5f88\u5e38\u89c1\u7684\u4ea4\u4e92\u6548\u679c\uff0c\u4f8b\u5982\u4e0b\u9762\u627e\u7684\u6548\u679c\u622a\u56fe\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/2021-11-09_165511.png\" width=\"340\" height=\"245\" alt=\"\u5bc6\u7801\u5f3a\u5ea6\u622a\u56fe\"><\/p>\n<p>\u8fd9\u79cd\u6548\u679c\u5b9e\u73b0\u6700\u597d\u7684\u65b9\u6cd5\u4e00\u5b9a\u662f\u4f7f\u7528 HTML <code>&lt;meter&gt;<\/code> \u5143\u7d20\uff0c\u65e0\u8bba\u662f\u8ddf\u968f\u5f3a\u5ea6\u7684 UI \u8272\u503c\u53d8\u5316\uff0c\u8fd8\u662f\u5f31\u4e2d\u5f3a\u7684\u6587\u5b57\u63d0\u793a\uff0c\u90fd\u662f\u53ef\u4ee5\u4f7f\u7528\u7eaf CSS \u5b9e\u73b0\uff0c\u65e0\u9700 JS \u53bb\u63a7\u5236 DOM \u7684\u8272\u503c\u4e0e\u5c3a\u5bf8\u53d8\u5316\u3002<\/p>\n<h3>\u4e00\u3001\u5148\u770b\u5b9e\u73b0\u6548\u679c<\/h3>\n<p>\u4e0b\u9762\u4e24\u5f20\u56fe\u5c31\u662f\u6700\u7ec8\u5728\u6d4f\u89c8\u5668\u4e2d\u5b9e\u73b0\u7684\u6548\u679c\u3002<\/p>\n<p>Chrome \u6d4f\u89c8\u5668\u4e0b\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/pwd-strong.gif\" width=\"355\" height=\"194\" alt=\"\u5bc6\u7801\u63d0\u793a\u5f3a\u5f31\" class=\"alignnone size-medium\" \/><\/p>\n<p>Safari \u6d4f\u89c8\u5668\u4e0b\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/890c3c64ddb.png\" width=\"621\" height=\"258\" alt=\"Safari\u6d4f\u89c8\u5668\u4e0b\u622a\u56fe\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u773c\u89c1\u4e3a\u5b9e\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u7684\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/202111\/form-password-strong-demo.php\" rel=\"noopener\" target=\"_blank\">meter\u5143\u7d20\u4e0e\u5bc6\u7801\u5f3a\u5ea6\u5b9e\u73b0demo<\/a><\/p>\n<p>\u63a5\u4e0b\u6765\u4e00\u6b65\u4e00\u6b65\u5e26\u5927\u5bb6\u4e86\u89e3\u5177\u4f53\u7684\u5b9e\u73b0\u8fc7\u7a0b\uff0c\u5148\u4ece\u4e86\u89e3 <code>&lt;meter&gt;<\/code> \u5143\u7d20\u5f00\u59cb\u3002<\/p>\n<h3>\u4e8c\u3001meter \u5143\u7d20\u57fa\u672c\u7279\u6027\u4e0e\u6548\u679c<\/h3>\n<p>\u5355\u8bcd meter \u76f4\u8bd1\u610f\u601d\u662f\u201c\u8ba1\u91cf\u5668\u201d\uff0c\u201c\u8ba1\u91cf\u8868\u201d\uff0c\u56e0\u6b64\uff0c\u5728 Web \u4e2d\uff0c\u4efb\u4f55\u4e0e\u4e08\u91cf\u76f8\u5173\uff0c\u540c\u65f6\u9700\u8981\u5206\u9636\u6bb5\u63d0\u793a\u7684\u573a\u666f\u90fd\u975e\u5e38\u4f7f\u7528\u4f7f\u7528 <code>&lt;meter&gt;<\/code> \u5143\u7d20\u3002<\/p>\n<p>\u4f8b\u5982\u6c7d\u8f66\u6cb9\u7bb1\u5269\u4f59\u6cb9\u91cf\uff0c\u964d\u96e8\u91cf\uff0c\u98ce\u5ea6\uff0c\u6e29\u5ea6\uff0c\u6e38\u620f\u4e2d\u4eba\u7269\u89d2\u8272\u7684\u8840\u91cf\u7b49\u3002<\/p>\n<p>\u5148\u770b\u4e0b\u9762\u4e00\u6bb5\u4ee3\u7801\uff1a<\/p>\n<pre>\u751f\u547d\u503c\uff1a&lt;meter min=\"0\" max=\"100\" low=\"30\" high=\"60\" optimum=\"80\" value=\"20\"&gt;&lt;\/meter&gt;\r\n\u751f\u547d\u503c\uff1a&lt;meter min=\"0\" max=\"100\" low=\"30\" high=\"60\" optimum=\"80\" value=\"50\"&gt;&lt;\/meter&gt;\r\n\u751f\u547d\u503c\uff1a&lt;meter min=\"0\" max=\"100\" low=\"30\" high=\"60\" optimum=\"80\" value=\"70\"&gt;&lt;\/meter&gt;<\/pre>\n<p>\u5728\u73b0\u4ee3\u6d4f\u89c8\u5668\u4e0b\u5c31\u4f1a\u6709\u5982\u4e0b\u56fe\u6240\u793a\u7684 UI \u6548\u679c\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/2021-11-09_174505.png\" width=\"159\" height=\"90\" alt=\"meter\u57fa\u672c\u6548\u679c\"><\/p>\n<p>\u4e0b\u9762\u5219\u662f\u5b9e\u65f6\u6e32\u67d3\u6548\u679c\uff0c\u5927\u5bb6\u53ef\u4ee5\u770b\u4e0b\u81ea\u5df1\u5f53\u524d\u8bbf\u95ee\u8bbe\u5907\u4e2d\u7684\u6548\u679c\uff1a<\/p>\n<p>\u751f\u547d\u503c\uff1a<meter min=\"0\" max=\"100\" low=\"30\" high=\"60\" optimum=\"80\" value=\"20\"><\/meter><\/p>\n<p>\u751f\u547d\u503c\uff1a<meter min=\"0\" max=\"100\" low=\"30\" high=\"60\" optimum=\"80\" value=\"50\"><\/meter><\/p>\n<p>\u751f\u547d\u503c\uff1a<meter min=\"0\" max=\"100\" low=\"30\" high=\"60\" optimum=\"80\" value=\"70\"><\/meter><\/p>\n<p>\u5176\u4e2d\u51fa\u73b0\u4e86 6 \u4e2a HTML \u5c5e\u6027\uff0c\u6b63\u597d\u6db5\u76d6\u4e86 <code>&lt;meter&gt;<\/code> \u5143\u7d20\u6240\u6709\u5e38\u7528\u5c5e\u6027\u3002<\/p>\n<h4>\u5c5e\u6027\u7b80\u4ecb<\/h4>\n<ul>\n<li><code>min<\/code> \u548c <code>max<\/code> \u5c5e\u6027\u8868\u793a\u6570\u503c\u8303\u56f4\uff0c\u9ed8\u8ba4\u662f 0-1\uff0c\u4e5f\u5c31\u662f\u5982\u679c <code>min<\/code> \u5c5e\u6027\u5982\u679c\u4e0d\u8bbe\u7f6e\uff0c\u5219\u8ba4\u4e3a\u662f 0\uff0c<code>max<\/code> \u5c5e\u6027\u4e0d\u8bbe\u7f6e\u5219\u8ba4\u4e3a\u662f 1\u3002<\/li>\n<li><code>value<\/code> \u8868\u793a\u5f53\u524d\u7684\u503c\uff0c\u9ed8\u8ba4\u662f 0\u3002<\/li>\n<li><code>low<\/code> \u548c <code>high<\/code> \u662f\u6bd4\u8f83\u7279\u6b8a\u7684 HTML \u5c5e\u6027\uff0c\u76ee\u524d\u4ec5\u51fa\u73b0\u5728 <code>&lt;meter&gt;<\/code> \u5143\u7d20\u4e0a\uff0c\u8868\u793a\u8b66\u6212\u503c\uff0c\u5176\u4e2d <code>low<\/code> \u8868\u793a\u8fc7\u4f4e\u8b66\u6212\u503c\uff0c<code>high<\/code> \u8868\u793a\u8fc7\u9ad8\u8b66\u6212\u503c\u3002\n<p>\u4f46\u662f\uff0c\u5927\u5bb6\u52a1\u5fc5\u6ce8\u610f\uff0c\u8fc7\u4f4e\u8fd8\u662f\u8fc7\u9ad8\u662f\u5426\u9700\u8981\u8b66\u6212\u8fd8\u9700\u8981\u4e00\u4e2a\u5c5e\u6027\u8fdb\u884c\u5224\u5b9a\uff0c\u90a3\u5c31\u662f <code>optimum<\/code> \u5c5e\u6027\u3002<\/p>\n<\/li>\n<li><code>optimum<\/code> \u5c5e\u6027\u8868\u793a\u6700\u4f73\u503c\uff0c\u7528\u6765\u51b3\u5b9a\u8fc7\u4f4e\u548c\u8fc7\u9ad8\u503c\u5c5e\u4e8e\u6b63\u5e38\u8fd8\u662f\u5f02\u5e38\uff0c\u8fd9\u4e2a\u5c5e\u6027\u5f88\u91cd\u8981\uff0c\u4e5f\u662f <code>&lt;meter&gt;<\/code> \u5143\u7d20\u5b66\u4e60\u7684\u96be\u70b9\u3002<\/li>\n<\/ul>\n<h4>optimum \u5c5e\u6027<\/h4>\n<p>optimum \u5c5e\u6027\u7684\u4f5c\u7528\u8868\u73b0\u63cf\u8ff0\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>\u5982\u679c <code>optimum<\/code> \u5c5e\u6027\u503c\u5728 <code>low<\/code> \u548c <code>high<\/code> \u4e4b\u95f4\uff0c\u5219\u8bf4\u660e <code>low<\/code> \u548c <code>high<\/code> \u90fd\u662f\u8b66\u6212\u503c\uff0c\u53ea\u6709\u5728\u8fd9\u4e2a\u533a\u95f4\u8303\u56f4\u7684\u503c\u624d\u662f\u6b63\u5e38\u7684\uff0c\u56e0\u6b64\uff0c\u6700\u7ec8\u7684\u8272\u503c\u72b6\u6001\u53ea\u4f1a\u6709\u4e24\u4e2a\uff0c\u5373\u6a59\u8272\u8b66\u6212\u548c\u7eff\u8272\u6b63\u5e38\u3002\n<p>    \u4ee3\u7801\u793a\u610f\uff1a<\/p>\n<pre>\u751f\u547d\u503c\uff1a&lt;meter max=\"100\" low=\"30\" high=\"60\" optimum=\"50\" value=\"20\"&gt;&lt;\/meter&gt;\r\n\u751f\u547d\u503c\uff1a&lt;meter max=\"100\" low=\"30\" high=\"60\" optimum=\"50\" value=\"50\"&gt;&lt;\/meter&gt;\r\n\u751f\u547d\u503c\uff1a&lt;meter max=\"100\" low=\"30\" high=\"60\" optimum=\"50\" value=\"70\"&gt;&lt;\/meter&gt;<\/pre>\n<p>\u6548\u679c\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u6700\u591a\u53ea\u4f1a\u51fa\u73b0\u4e24\u79cd\u989c\u8272\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/2021-11-09_190748.png\" width=\"166\" height=\"92\" alt=\"\u4e24\u79cd\u8272\u503c\">\n<\/li>\n<li>\n        \u5982\u679c <code>optimum<\/code> \u5c5e\u6027\u503c\u6bd4 <code>low<\/code> \u8fd8\u8981\u5c0f\uff0c\u5219\u8bf4\u660e low \u5e76\u4e0d\u662f\u8b66\u6212\u7ebf\uff0c\u53cd\u800c\u662f\u63a8\u8350\u7ebf\uff0c\u4e5f\u5c31\u662f\u8d8a\u5c0f\u53cd\u800c\u8d8a\u9ad8\uff0c\u6b64\u65f6\uff0clow-high \u4e4b\u95f4\u7684\u8303\u56f4\u5c31\u5c5e\u4e8e\u8b66\u6212\uff0c\u800c\u8d85\u8fc7 high \u7684\u503c\u5c31\u5c5e\u4e8e\u5371\u9669\u4e86\u3002<\/p>\n<p>        \u4e8e\u662f\uff0c\u6700\u7ec8 <code>&lt;meter&gt;<\/code> \u5143\u7d20\u53ef\u4ee5\u6709 3 \u6bb5\u8272\u503c\u72b6\u6001\uff0cHTML \u4ee3\u7801\u793a\u610f\uff1a<\/p>\n<pre>\u751f\u547d\u503c\uff1a&lt;meter max=\"100\" low=\"30\" high=\"60\" optimum=\"20\" value=\"20\"&gt;&lt;\/meter&gt;\r\n\u751f\u547d\u503c\uff1a&lt;meter max=\"100\" low=\"30\" high=\"60\" optimum=\"20\" value=\"50\"&gt;&lt;\/meter&gt;\r\n\u751f\u547d\u503c\uff1a&lt;meter max=\"100\" low=\"30\" high=\"60\" optimum=\"20\" value=\"70\"&gt;&lt;\/meter&gt;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/2021-11-09_191225.png\" width=\"173\" height=\"95\" alt=\"meter \u4e09\u6bb5\u8272\u503c\u6f14\u793a\">\n    <\/li>\n<li>\u5982\u679c <code>optimum<\/code> \u5c5e\u6027\u503c\u6bd4 <code>high<\/code> \u8fd8\u8981\u5927\uff0c\u4e5f\u4f1a\u51fa\u73b0 3 \u6bb5\u8272\u503c\u72b6\u6001\uff0c\u6b64\u65f6\uff0c\u5927\u4e8e high \u7684\u503c\u4f1a\u88ab\u8ba4\u4e3a\u662f\u6b63\u5e38\u7684\uff0c\u56e0\u6b64\u8868\u73b0\u4e3a\u7eff\u8272\uff0c\u8fd9\u4e2a\u6548\u679c\uff0c\u5c31\u662f\u4e00\u5f00\u59cb\u90a3\u4e2a\u4f8b\u5b50\u6240\u6f14\u793a\u7684\u90a3\u4e2a\u6548\u679c\uff0c\u4ee3\u7801\u548c\u622a\u56fe\u6548\u679c\u662f\u8fd9\u6837\u7684\uff1a\n<pre>\u751f\u547d\u503c\uff1a&lt;meter max=\"100\" low=\"30\" high=\"60\" optimum=\"80\" value=\"20\"&gt;&lt;\/meter&gt;\r\n\u751f\u547d\u503c\uff1a&lt;meter max=\"100\" low=\"30\" high=\"60\" optimum=\"80\" value=\"50\"&gt;&lt;\/meter&gt;\r\n\u751f\u547d\u503c\uff1a&lt;meter max=\"100\" low=\"30\" high=\"60\" optimum=\"80\" value=\"70\"&gt;&lt;\/meter&gt;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/2021-11-09_174505.png\" width=\"159\" height=\"90\" alt=\"meter\u57fa\u672c\u6548\u679c\"><\/li>\n<\/ul>\n<p>\u56de\u5230\u672c\u6587\u8fd9\u91cc\uff0c\u7531\u4e8e\u5bc6\u7801\u5f3a\u5ea6\u8d8a\u5f3a\u8d8a\u597d\uff0c\u56e0\u6b64\uff0c\u5f88\u663e\u7136\uff0c\u9700\u8981\u8bbe\u7f6e <code>optimum<\/code> \u5c5e\u6027\u503c\u6bd4 <code>high<\/code> \u8fd8\u8981\u5927\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u6211\u4eec\u9700\u8981\u7684\u662f\u4e0b\u56fe\u8fd9\u6837\u7684\u6548\u679c\uff0c\u9700\u8981\u660e\u663e\u5206\u6bb5\u7684\uff0c\u800c\u6d4f\u89c8\u5668\u9ed8\u8ba4\u7684 <code>&lt;meter&gt;<\/code> \u5143\u7d20\u6548\u679c\u5c31\u662f\u4e2a\u8272\u6761\uff0c\u4e0d\u7b26\u5408\u4ea7\u54c1\u9700\u6c42\uff0c\u90a3\u6709\u6ca1\u6709\u4ec0\u4e48\u529e\u6cd5\u81ea\u5b9a\u4e49 UI \u5462\uff1f<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/2021-11-09_192018.png\" width=\"273\" height=\"47\" alt=\"\u76ee\u6807\u5bc6\u7801\u5f3a\u5ea6\u6548\u679c\"><\/p>\n<h3>\u4e8c\u3001meter \u5143\u7d20\u7684\u6837\u5f0f\u81ea\u5b9a\u4e49<\/h3>\n<p>\u5728\u73b0\u4ee3\u6d4f\u89c8\u5668\u4e0b\uff0c<code>&lt;meter&gt;<\/code> \u5143\u7d20\u63d0\u4f9b\u4e86\u82e5\u5e72\u4f2a\u5143\u7d20\uff0c\u53ef\u4ee5\u8ba9\u6211\u4eec\u5bf9 <code>&lt;meter&gt;<\/code> \u5143\u7d20\u8fdb\u884c\u6837\u5f0f\u81ea\u5b9a\u4e49\u3002<\/p>\n<p>\u5176\u4e2d\uff0cChrome \u6d4f\u89c8\u5668\u548c Safari \u6d4f\u89c8\u5668\u53ef\u4ee5\u4f7f\u7528\u7684\u4f2a\u5143\u7d20\u975e\u5e38\u4e30\u5bcc\uff0cFirefox \u6d4f\u89c8\u5668\u76f8\u5bf9\u5c11\u4e00\u4e9b\u3002<\/p>\n<p>\u8fd9\u91cc\uff0c\u4e3b\u8981\u4ee5  Chrome \u6d4f\u89c8\u5668\u793a\u610f\u3002<\/p>\n<p>\u6240\u6709\u53ef\u4ee5\u8bbe\u7f6e <code>&lt;meter&gt;<\/code> \u5143\u7d20\u7684\u9009\u62e9\u5668\u5305\u62ec\u4e0b\u9762\u8fd9\u4e9b\uff1a<\/p>\n<ul>\n<li>meter \u5143\u7d20\u81ea\u8eab\u9009\u62e9\u5668\uff1b<\/li>\n<li>::-webkit-meter-inner-element {}<\/li>\n<li>::-webkit-meter-bar {} \u7070\u8272\u80cc\u666f\u6761\u3002<\/li>\n<li>::-webkit-meter-even-less-good-value {} \u7ea2\u8272\u3002<\/li>\n<li>::-webkit-meter-optimum-value {} \u6a59\u8272\u3002<\/li>\n<li>::-webkit-meter-suboptimum-value {} \u7eff\u8272\u3002<\/li>\n<\/ul>\n<p>\u5404\u4e2a\u4f2a\u5143\u7d20\u6240\u5bf9\u5e94\u7684 DOM \u5c42\u7ea7\u7ed3\u6784\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/2021-11-11_135433.png\" width=\"700\" height=\"302\" alt=\"\u4f2a\u5143\u7d20\u7ed3\u6784\"><\/p>\n<p>\u4f7f\u7528\u5b57\u7b26\u56fe\u5f62\u8868\u793a\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<pre>meter\r\n  |-- ::-webkit-meter-inner-element\r\n    |-- ::-webkit-meter-bar\r\n      |-- ::-webkit-meter-even-less-good-value  -|\r\n      |-- ::-webkit-meter-suboptimum-value      -|--&gt; \u53ea\u4f1a\u540c\u65f6\u51fa\u73b01\u4e2a\r\n      |-- ::-webkit-meter-optimum-value         -|\r\n<\/pre>\n<p>\u6240\u4ee5\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e0a\u9762\u7684\u4f2a\u5143\u7d20\u5b9e\u73b0\u6211\u4eec\u60f3\u8981\u7684 UI \u6548\u679c\u4e86\u3002<\/p>\n<p>\u7136\u800c\uff0c\u4e8b\u60c5\u5e76\u6ca1\u6709\u9884\u60f3\u7684\u90a3\u4e48\u7b80\u5355\u3002<\/p>\n<ol>\n<li>\u5bc6\u7801\u5f3a\u5ea6\u5982\u4f55\u786e\u5b9a\uff1f<\/li>\n<li>\u8868\u793a 3 \u4e2a\u989c\u8272\u7684\u4f2a\u5143\u7d20\u6700\u591a\u53ea\u4f1a\u51fa\u73b0 1 \u4e2a\uff0c\u800c\u6211\u4eec\u7684\u76ee\u6807\u6548\u679c\u5374\u662f 3 \u8272\u540c\u65f6\u663e\u793a\uff0c\u53e6\u5916\uff0c\u9ed8\u8ba4\u7684\u8272\u503c\u662f\u8fde\u7eed\u7684\uff0c\u800c\u9700\u8981\u7684\u6548\u679c\u662f\u5206\u6bb5\u7684\uff0c\u8be5\u600e\u4e48\u5b9e\u73b0\u5462\uff1f<\/li>\n<li>\u5f3a\u5ea6\u8272\u5757\u4e0b\u9762\u8fd8\u6709\u201c\u5f31 \u4e2d \u5f3a\u201d\u7684\u6587\u5b57\u63d0\u793a\uff0c\u8fd9\u4e2a\u5e03\u5c40\u6548\u679c\u53c8\u8be5\u5982\u4f55\u5b9e\u73b0\u5462\uff1f<\/li>\n<\/ol>\n<p>\u5173\u4e8e\u8fd9\u4e9b\u5b9e\u73b0\u96be\u70b9\uff0c\u6211\u4eec\u4e00\u4e2a\u4e00\u4e2a\u6765\u770b\u4e0b\uff0c\u5176\u4e2d\u4e0d\u4e4f\u4e00\u4e9b\u6709\u521b\u610f\u7684\u5b9e\u73b0\u6280\u5de7\u3002<\/p>\n<p><span class=\"hidden\">\/\/zxx: \u5982\u679c\u4f60\u770b\u5230\u8fd9\u6bb5\u6587\u5b57\uff0c\u8bf4\u660e\u4f60\u73b0\u5728\u8bbf\u95ee\u662f\u4e0d\u662f\u539f\u6587\u7ad9\u70b9\uff0c\u66f4\u597d\u7684\u9605\u8bfb\u4f53\u9a8c\u5728\u8fd9\u91cc\uff1ahttps:\/\/www.zhangxinxu.com\/wordpress\/?p=10188\uff08\u4f5c\u8005\u5f20\u946b\u65ed\uff09<\/span><\/p>\n<h3>\u56db\u3001\u5bc6\u7801\u5f3a\u5ea6\u7684\u8ba1\u7b97<\/h3>\n<p>\u5bc6\u7801\u5f3a\u5ea6\u7684\u8ba1\u7b97\u76f4\u63a5\u4f7f\u7528\u5f00\u6e90\u7684\u516c\u8ba4\u7684\u7b97\u6cd5\u5c31\u53ef\u4ee5\u4e86\uff0c\u6bd4\u65b9\u8bf4 zxcvbn\uff1a<a href=\"https:\/\/github.com\/dropbox\/zxcvbn\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/github.com\/dropbox\/zxcvbn<\/a><\/p>\n<p>\u4f7f\u7528\u4e5f\u76f8\u5f53\u7b80\u5355\uff0c\u5f15\u5165\u7136\u540e\u6267\u884c\uff0c\u793a\u610f\uff1a<\/p>\n<pre>&lt;script src=\"https:\/\/cdn.bootcdn.net\/ajax\/libs\/zxcvbn\/4.4.2\/zxcvbn.js\"&gt;&lt;\/script&gt;\r\n&lt;script&gt;\r\n    let objResult = zxcvbn('your password');\r\n&lt;\/script&gt;<\/pre>\n<p>\u5176\u4e2d objResult \u5305\u542b\u4e0b\u9762\u8fd9\u4e9b\u5c5e\u6027\uff1a<\/p>\n<pre>{\r\n    guesses: Number\r\n    guesses_log10: Number\r\n    score: Number (0-4)\r\n    crack_times_seconds: Object \uff08\u4e0d\u540c\u8fd0\u7b97\u529b\u4e0b\u7684\u7834\u89e3\u65f6\u95f4\uff0c\u6570\u503c\u5c55\u793a\uff09\r\n    crack_times_display: Object \uff08\u4e0d\u540c\u8fd0\u7b97\u529b\u4e0b\u7684\u7834\u89e3\u65f6\u95f4\uff0c\u5b57\u7b26\u63cf\u8ff0\u5c55\u793a\uff09\r\n    sequence: Array \u9a8c\u8bc1\u5e8f\u5217\r\n    feedback: \u53cd\u9988\u4e0e\u5efa\u8bae\r\n    calc_time: zxcvbn \u8ba1\u7b97\u6b64\u5bc6\u7801\u5f3a\u5ea6\u82b1\u8d39\u7684\u65f6\u95f4\uff0c\u5355\u4f4d\u662f\u6beb\u79d2 ms\r\n}<\/pre>\n<p>\u622a\u56fe\u793a\u610f\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/2021-11-11_151752.png\" width=\"313\" height=\"224\" alt=\"\u8fd0\u884c\u7ed3\u679c\"><\/p>\n<p>\u5176\u4e2d\uff0c\u4e0e\u5bc6\u7801\u5f3a\u5ea6\u76f4\u63a5\u76f8\u5173\u7684\u662f\uff1aguesses\u3001guesses_log10 \u548c score\u3002<\/p>\n<p>\u5176\u4e2d\uff0cscore \u8303\u56f4\u662f 0-4\uff0c\u6570\u503c\u8d8a\u5927\uff0c\u5bc6\u7801\u8d8a\u5b89\u5168\uff0c\u867d\u7136\u4e5f\u80fd\u89e3\u51b3\u5f3a\u5ea6\u7684\u5224\u65ad\uff0c\u4f46\u662f\u4f53\u73b0\u5728 <code>&lt;meter&gt;<\/code> \u5143\u7d20\u4e0a\u5c31\u6ca1\u6709\u4e86\u4e30\u5ea6\u7684 value \u53d8\u5316\uff0c\u89c6\u89c9\u6548\u679c\u4e5f\u4e0d\u548b\u5730\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u5728\u672c\u6587\u6240\u63cf\u8ff0\u7684\u573a\u666f\u4e0b\uff0c\u6211\u4eec\u4f7f\u7528 guesses_log10 \u4f5c\u4e3a\u6211\u4eec\u7684\u5f3a\u5ea6\u5224\u65ad\u503c\u3002<\/p>\n<p>\u6839\u636e\u6211\u7684\u6d4b\u8bd5\uff0cguesses_log10 \u7684\u503c\u5728 12 \u4ee5\u4e0a\uff0c\u5bc6\u7801\u5f3a\u5ea6\u5c31\u5df2\u7ecf\u5f88 Strong \u4e86\uff0c\u8003\u8651\u5230\u5f31\u4e2d\u5f3a\u4e09\u79cd\u72b6\u6001\u7684\u8272\u6761\u8303\u56f4\u662f\u4e09\u7b49\u5206\u7684\uff0c\u56e0\u6b64\uff0c\u6700\u7ec8\u7684 <code>&lt;meter&gt;<\/code> \u5143\u7d20\u7684\u9ad8\u4f4e\u503c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>&lt;meter min=\"0\" max=\"12\" low=\"4\" high=\"8\" optimum=\"10\"&gt;&lt;\/meter&gt;<\/pre>\n<p>\u76f8\u5173 JS \u4ee3\u7801\u5219\u662f\u8fd9\u6837\u5b50\u7684\uff1a<\/p>\n<pre>meter.value = zxcvbn('paddworld').guesses_log10;<\/pre>\n<p>\u5269\u4e0b\u7684\u89c6\u89c9\u8868\u73b0\u7684\u5de5\u4f5c\u5168\u90e8\u90fd\u4ea4\u7ed9 CSS \u597d\u4e86\u3002<\/p>\n<h3>\u4e94\u3001\u6700\u7ec8\u6837\u5f0f\u5b9e\u73b0\u7684\u7ec6\u8282<\/h3>\n<h4>1. \u80cc\u666f\u6761\u7684\u6837\u5f0f<\/h4>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u786e\u5b9a\u4e2a\u5c3a\u5bf8\uff0c\u5047\u8bbe \u957f\u5ea6\u662f 120px\uff0c\u9ad8\u5ea6\u662f 12px\uff1a<\/p>\n<pre>::-webkit-meter-bar {\r\n    width: 120px;\r\n    height: 12px;\r\n}<\/pre>\n<p>\u6d4f\u89c8\u5668\u9ed8\u8ba4\u7684\u8fb9\u6846\u6548\u679c\u662f\u4e0d\u9700\u8981\u7684\uff0c\u7136\u540e\u4e3a\u4e86\u517c\u5bb9\u6027\uff0c\u9700\u8981\u7edf\u4e00\u80cc\u666f\u8272\uff0c\u4e8e\u662f\u6709\uff1a<\/p>\n<pre>::-webkit-meter-bar {\r\n    width: 120px; height: 12px;\r\n    border: 0;\r\n    background: #eee;\r\n}<\/pre>\n<p>Firefox \u6d4f\u89c8\u5668\u53ef\u4ee5\u4f7f\u7528 ::-moz-meter-bar \u4f2a\u5143\u7d20\u8bbe\u7f6e\u3002<\/p>\n<h4>2. \u8272\u5e26\u7684\u5b9e\u73b0<\/h4>\n<p>\u6d4f\u89c8\u5668\u9ed8\u8ba4\u7684\u72b6\u6001\u90fd\u662f\u7eaf\u8272\uff0c\u4ece\u5de6\u7eaf\u5230\u53f3\uff0c\u60f3\u8981\u53d8\u6210\u4e00\u4e2a\u4e00\u4e2a\u7684\u8272\u5e26\uff0c\u4e0d\u5c11\u4eba\u7684\u60f3\u6cd5\u4f1a\u662f\u53e0\u52a0\uff0c\u4e5f\u5c31\u662f\u51e0\u4e2a <code>&lt;meter&gt;<\/code> \u5143\u7d20\u53e0\u52a0\u5728\u4e00\u8d77\uff0c\u5176\u5b9e\u4e0d\u9700\u8981\u8fd9\u4e48\u9ebb\u70e6\u7684\uff0c\u6211\u4eec\u4f7f\u7528 CSS \u6e10\u53d8\u6a21\u62df\u5c31\u597d\u4e86\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u8fdb\u5165\u6a59\u8272\u72b6\u6001\u7684\u65f6\u5019\uff0c\u628a\u524d 1\/3 \u90e8\u5206\u6539\u6210\u7ea2\u8272\uff08\u539f\u6765\u662f\u6a59\u8272\uff09\uff0c\u8fd9\u6837\uff0c\u5f53\u72b6\u6001\u6761\u4ece\u7ea2\u8272\u53d8\u6210\u6a59\u8272\u7684\u65f6\u5019\uff0c\u5c31\u50cf\u662f\u65e0\u7f1d\u6dfb\u52a0\u7684\uff0c\u800c\u4e0d\u662f\u7a81\u7136\u66ff\u6362\uff0c\u7eff\u8272\u8fd9\u90e8\u5206\u4e5f\u662f\u7c7b\u4f3c\u7684\u3002<\/p>\n<p>\u4ee3\u7801\u793a\u610f\uff1a<\/p>\n<pre>::-webkit-meter-even-less-good-value {\r\n    background: red;\r\n}\r\n::-webkit-meter-suboptimum-value {\r\n    background: linear-gradient(to right, red 40px, orange 0);\r\n}\r\n::-webkit-meter-optimum-value {\r\n    background: linear-gradient(to right, red 40px, orange 0 80px, green 0);\r\n}<\/pre>\n<p>\u4ee5 <code>::-webkit-meter-optimum-value<\/code> \u4f2a\u5143\u7d20\u4e3e\u4f8b\uff0c\u6d4f\u89c8\u5668\u9ed8\u8ba4\u72b6\u6001\u4e0b\uff0c\u8fd9\u4e2a\u4f2a\u5143\u7d20\u662f\u7eaf\u7eff\u8272\uff0c\u8fd9\u91cc\u4f7f\u7528 CSS \u6e10\u53d8\u91cd\u65b0\u5b9e\u73b0\u4e4b\u540e\uff0c\u5c31\u662f \u7ea2-\u6a59-\u7eff \u4e09\u6bb5\uff0c\u5f88\u597d\u5730\u6a21\u62df\u4e86\u4e09\u6001\u5f3a\u5ea6\u6548\u679c\u3002<\/p>\n<p>\u6700\u7ec8\u7684\u6548\u679c\u53ef\u4ee5\u53c2\u89c1\u4e0b\u9762\u7684 GIF \u5f55\u5c4f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/pwd-ui.gif\" width=\"411\" height=\"37\" alt=\"\u4e09\u8272\u6a21\u62df\u6548\u679c\"><\/p>\n<h4>3. \u4e2d\u95f4\u9542\u7a7a\u5206\u9694<\/h4>\n<p>\u4e0a\u9762\u7684 GIF \u6548\u679c\uff0c\u5404\u4e2a\u8272\u5757\u662f\u7d27\u5bc6\u76f8\u8fde\u7684\uff0c\u4f46\u662f\u6700\u7ec8\u9700\u8981\u7684\u6548\u679c\u662f\u5f7c\u6b64\u4e4b\u95f4\u6709\u95f4\u9699\uff0c\u8fd9\u4e2a\u8be5\u5982\u4f55\u5b9e\u73b0\u5462\uff1f<\/p>\n<p>\u65b9\u6cd5\u5176\u5b9e\u633a\u591a\u7684\uff0c\u6211\u8fd9\u91cc\u9009\u62e9\u4f7f\u7528\u906e\u7f69\u5b9e\u73b0\uff0c\u5728\u8272\u5757\u7684\u5bb9\u5668\u5143\u7d20\u4e0a\u7ed8\u5236\u4e00\u4e2a\u9542\u7a7a\u6e10\u53d8\u4f5c\u4e3a\u906e\u7f69\u56fe\u50cf\uff1a<\/p>\n<pre>::-webkit-meter-bar {\r\n    -webkit-mask: linear-gradient(to right, \r\n      red 39px, \r\n      transparent 0 41px, \r\n      orange 0 79px, \r\n      transparent 0 81px, \r\n      green 0\r\n    );\r\n}<\/pre>\n<p>\u6b64\u65f6\uff0c\u6548\u679c\u5c31\u4f1a\u662f\u8fd9\u6837\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/pwd-ui2.gif\" width=\"411\" height=\"37\" alt=\"\u5e26\u95f4\u9699\u7684\u5f3a\u5ea6\u6548\u679c\"><\/p>\n<h4>4. \u6587\u5b57\u5de6\u4e2d\u53f3\u5bf9\u9f50\u5b9e\u73b0<\/h4>\n<p>\u63a5\u4e0b\u6765\u5c31\u662f\u201c\u5f31\u4e2d\u5f3a\u201d\u4e09\u4e2a\u6587\u5b57\u7684\u6548\u679c\u5b9e\u73b0\u4e86\uff0c\u5982\u4e0b\u56fe\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/2021-11-09_192018.png\" width=\"273\" height=\"47\" alt=\"\u76ee\u6807\u5bc6\u7801\u5f3a\u5ea6\u6548\u679c\"><\/p>\n<p>\u6709\u4eba\u4f1a\u60f3\u5230\u4f7f\u7528\u4e00\u4e2a <code>&lt;span&gt;<\/code> \u5143\u7d20\u548c <code>&lt;meter&gt;<\/code> \u5143\u7d20\u5305\u5728\u4e00\u8d77\u518d\u91cd\u5b9a\u4f4d\uff0c\u8fd9\u4e2a\u867d\u7136\u4e5f\u80fd\u5b9e\u73b0\uff0c\u4f46\u662f HTML \u5c31\u5570\u55e6\u4e86\uff0c\u4ee5\u540e\u4e5f\u4e0d\u592a\u597d\u7ef4\u62a4\u3002<\/p>\n<p>\u5b9e\u9645\u4e0a\uff0c\u76f4\u63a5\u4f7f\u7528 <code>&lt;meter&gt;<\/code> \u5143\u7d20\u5c31\u53ef\u4ee5\u5b9e\u73b0\uff0c\u65b9\u6cd5\u5c31\u662f <code>::after<\/code> \u4f2a\u5143\u7d20\u3002<\/p>\n<pre>meter::after {\r\n    content: '\u5f31\u4e2d\u5f3a';\r\n}<\/pre>\n<p>\u6548\u679c\u5982\u4e0b\u622a\u56fe\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/2021-11-11_170843.png\" width=\"372\" height=\"46\" alt=\"\u6587\u5b57\u663e\u793a\u6548\u679c\"><\/p>\n<p>\u4e0d\u8fc7\u6709\u51e0\u4e2a\u95ee\u9898\uff0c\u9996\u5148\uff0c\u6587\u5b57\u5360\u636e\u7684\u5c3a\u5bf8\u7a7a\u95f4\uff0c\u5f71\u54cd\u4e86\u548c\u8f93\u5165\u6846\u7684\u5782\u76f4\u5bf9\u9f50\uff0c\u8fd9\u4e2a\u597d\u529e\uff0c\u8bbe\u7f6e\u4e3a\u7edd\u5bf9\u5b9a\u4f4d\u5c31\u53ef\u4ee5\u4e86\uff1a<\/p>\n<pre>meter::after {\r\n    content: '\u5f31\u4e2d\u5f3a';\r\n    position: absolute;\r\n}<\/pre>\n<p>\u4f46\u662f\uff0c\u201c\u5f31\u4e2d\u5f3a\u201d\u4e09\u4e2a\u5b57\u8981\u5206\u522b\u5728 3 \u4e2a\u989c\u8272\u7247\u6bb5\u7684\u4e2d\u95f4\uff0c\u8fd9\u4e2a\u5bf9\u9f50\u8be5\u600e\u4e48\u5b9e\u73b0\u5462\uff1f<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u8ba9\u4f2a\u5143\u7d20\u5bbd\u5ea6\u5145\u6ee1 <code>&lt;meter&gt;<\/code> \u5143\u7d20\uff0c\u7ed9\u6587\u5b57\u4e2d\u95f4\u589e\u52a0\u7a7a\u683c\u3001\u672b\u5c3e\u589e\u52a0\u4e00\u4e32\u957f\u957f\u7684\u8fde\u7eed\u82f1\u6587\u5b57\u7b26\u5b9e\u73b0\uff1a<\/p>\n<pre>meter {\r\n    position: relative;    \r\n}\r\nmeter::after {\r\n    content: '\u5f31 \u4e2d \u5f3a aaaaaaaaaaaaaaaaaaaaaa';\r\n    position: absolute;\r\n    left: 0; right: 0;\r\n    \/* \u4e24\u7aef\u5bf9\u9f50 *\/\r\n    text-align: justify;\r\n    \/* \u9690\u85cf aaaaaaaaaaaaaaaaaaaaaa *\/\r\n    height: 20px;\r\n    line-height: 20px;\r\n    overflow: hidden;\r\n}<\/pre>\n<p>\u4e3a\u4ec0\u4e48\u540e\u9762\u9700\u8981\u4e00\u6bb5\u83ab\u540d\u5176\u5999\u7684 <code>'aaaaaaaaaaaaaaaaaaaaaa'<\/code> \u5462\uff0c\u56e0\u4e3a\u4e24\u7aef\u5bf9\u9f50\u6548\u679c\u7684\u5b9e\u73b0\uff0c\u5904\u7406\u5b57\u7b26\u4e4b\u95f4\u6709\u7a7a\u683c\uff0c\u8fd8\u9700\u8981\u5185\u5bb9\u8d85\u8fc71\u884c\uff0c\u800c\u8fde\u7eed\u82f1\u6587\u5b57\u7b26\u9ed8\u8ba4\u662f\u4e0d\u4f1a\u6362\u884c\u7684\uff0c\u56e0\u6b64\u4f1a\u4f5c\u4e3a\u6574\u4f53\u5728\u7b2c 2 \u884c\u663e\u793a\uff0c\u4ece\u800c\u8ba9\u7b2c\u4e00\u884c\u7684 \u201c\u5f31\u4e2d\u5f3a\u201d\u4e09\u4e2a\u5b57\u4e24\u7aef\u5bf9\u9f50\u3002<\/p>\n<p>\u6548\u679c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/2021-11-11_172333.png\" width=\"374\" height=\"57\" alt=\"\u6587\u5b57\u5bf9\u9f50\u6548\u679c\"><\/p>\n<p>\u6211\u731c\uff0c\u6709\u4eba\u4f1a\u8bf4\uff0c\u4e0d\u5bf9\u554a\uff0c\u201c\u5f31\u201d\u548c\u201c\u5f3a\u201d\u4e24\u4e2a\u5b57\u9700\u8981\u5728\u8272\u5757\u7684\u4e2d\u95f4\u554a\uff0c\u4e0d\u662f\u8fb9\u4e0a\u3002<\/p>\n<p>\u5bf9\uff0c\u8fb9\u4e0a\u662f\u4e0d\u5bf9\u7684\uff0c\u6240\u4ee5\uff0c\u9700\u8981\u4fee\u6539\u4e0b <code>left<\/code> \u548c <code>top<\/code> \u4f4d\u7f6e\u5fae\u8c03\u4e0b\uff08\u4e2d\u6587\u5b57\u7b26\u5360\u636e\u5bbd\u5ea6\u662f 1em\uff09\uff1a<\/p>\n<pre>meter {\r\n    position: relative;    \r\n}\r\nmeter::after {\r\n    content: '\u5f31 \u4e2d \u5f3a aaaaaaaaaaaaaaaaaaaaaa';\r\n    position: absolute;\r\n    left: calc(20px - .5em);\r\n    right: calc(20px - .5em);\r\n    \/* \u4e24\u7aef\u5bf9\u9f50 *\/\r\n    text-align: justify;\r\n    \/* \u9690\u85cf aaaaaaaaaaaaaaaaaaaaaa *\/\r\n    height: 20px;\r\n    line-height: 20px;\r\n    overflow: hidden;\r\n}<\/pre>\n<p>\u6548\u679c\u4e3a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/2021-11-11_173811.png\" width=\"373\" height=\"54\" alt=\"\u5bf9\u9f50\u6548\u679c\"><\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u5c31\u662f\u6587\u5b57\u53d8\u8272\u7684\u5b9e\u73b0\u4e86\u3002<\/p>\n<h4>5. \u4e0d\u540c\u6587\u5b57\u4e0d\u540c\u989c\u8272\u5b9e\u73b0<\/h4>\n<p>\u540c\u4e00\u6bb5\u6587\u5b57\u663e\u793a\u4e0d\u540c\u989c\u8272\u7684\u6280\u672f\u5176\u5b9e\u5f88\u591a\u5f88\u591a\u5e74\u524d\uff0810\u5e74\u524d\uff09\u5c31\u4ecb\u7ecd\u8fc7\u4e86\uff0c\u8be6\u89c1\uff1a\u201c<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=1601\">CSS3\u4e0b\u7684\u6e10\u53d8\u6587\u5b57\u6548\u679c\u5b9e\u73b0<\/a>\u201d\uff0c\u5728\u300aCSS\u65b0\u4e16\u754c\u300b\u8fd9\u672c\u4e66\u4e2d\u4e5f\u6709\u4ecb\u7ecd\u3002<\/p>\n<p>\u8fd9\u91cc\u4f7f\u7528 <code>background-clip:text<\/code>\u52a0 linear-gradient \u6e10\u53d8\u80cc\u666f\u5b9e\u73b0\u7684\u3002<\/p>\n<pre>meter::after {\r\n    -webkit-text-fill-color: transparent;\r\n    background-image: linear-gradient(to right, \r\n        red 39px, \r\n        transparent 0 41px, \r\n        orange 0 79px, \r\n        transparent 0 81px, \r\n        green 0\r\n    );\r\n    -webkit-background-clip: text;\r\n}<\/pre>\n<p>\u518d\u52a0\u4e0a\u4e00\u4e9b\u5c3a\u5bf8\u548c\u4f4d\u7f6e\u7684\u7ec6\u8282\u8c03\u6574\uff0c\u4e8e\u662f\u5c31\u6709\u4e86\u6700\u7ec8\u7684\u6548\u679c\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/pwd-ui3.gif\" width=\"411\" height=\"49\" alt=\"\u6700\u7ec8\u6e10\u53d8\u6587\u5b57\u6548\u679c\"><\/p>\n<h4>6. Safari \u6d4f\u89c8\u5668<\/h4>\n<p>\u597d\uff0cChrome \u6d4f\u89c8\u5668\u641e\u5b9a\u4e86\uff0c\u770b\u770b Safari \u6d4f\u89c8\u5668\u4e0b\u7684\u6548\u679c\uff0c\u7ed3\u679c\u2026\u2026\u5443\u2026\u2026\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/cade637c61.png\" width=\"348\" height=\"79\" alt=\"Safari\u4e0b\u6548\u679c\" class=\"alignnone imgpad size-medium\" \/><\/p>\n<p>\u672c\u4ee5\u4e3a\u662fsafari\u6d4f\u89c8\u5668\u4e0d\u652f\u6301\uff0c\u540e\u6765\u7814\u7a76\u4e86\u4e00\u4e0b\uff0c\u53d1\u73b0\u539f\u6765\u53ea\u9700\u8981\u8bbe\u7f6e\u5916\u9762\u7684meter \u5143\u7d20\u8fb9\u6846\u5c3a\u5bf8\u4e3a0\u6216none\u5c31\u53ef\u4ee5\u89e6\u53d1\u4f2a\u5143\u7d20\u91cd\u5b9a\u4e49\u4e86\uff0c\u4e5f\u5c31\u662f\uff1a<\/p>\n<pre>meter {\r\n    border: 0;\r\n}<\/pre>\n<p>\u6240\u6709\u7684\u6548\u679c\u5c31\u4f1a\u51fa\u73b0\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/safari-2.png\" width=\"355\" height=\"78\" alt=\"\u5bc6\u7801\u6548\u679cSafari\" class=\"alignnone imgpad  size-medium\" \/><\/p>\n<h4>7. \u4f7f\u7528 CSS \u53d8\u91cf\u4f18\u5316<\/h4>\n<p>\u6700\u540e\u628a\u4e0a\u9762\u6240\u6709\u7684\u5b9e\u73b0\u6574\u5408\u4e00\u4e0b\uff0c\u540c\u65f6\u4f7f\u7528css\u53d8\u91cf\u4f18\u5316\u4e00\u4e0b\u6e10\u53d8\u4ee5\u53ca\u5c3a\u5bf8\u3002\u5c31\u4f1a\u5f97\u5230\u5982\u4e0b\u6240\u793a\u7684\u7ec8\u6781\u4ee3\u7801\uff1a<\/p>\n<pre>meter {\r\n     --size: 60px;\r\n     --gradient: linear-gradient(to right, red calc(var(--size) - 1px), transparent 0 calc(var(--size) + 1px), orange 0 calc(var(--size) * 2 - 1px), transparent 0 calc(var(--size) * 2 + 1px), green 0);\r\n    width: calc(3 * var(--size));\r\n    border: 0; \/* Safari *\/\r\n    position: relative;\r\n}\r\nmeter::after {\r\n    content: '\u5f31 \u4e2d \u5f3a aaaaaaaaaaaaaaaaaaaaaa';\r\n    position: absolute;\r\n    font-size: 14px;\r\n    line-height: 20px;\r\n    height: 20px;\r\n    overflow: hidden;\r\n    left: calc(var(--size) \/ 2 - .5em);\r\n    right: calc(var(--size) \/ 2 - .5em);\r\n    text-align: justify;\r\n    -webkit-text-fill-color: transparent;\r\n    background: var(--gradient) calc(.5em - var(--size) \/ 2) \/ calc(3 * var(--size));\r\n    -webkit-background-clip: text;\r\n}\r\n::-webkit-meter-bar {\r\n    height: 12px;\r\n    width: calc(3 * var(--size));\r\n    border: 0;\r\n    background: #eee;\r\n    -webkit-mask: var(--gradient);\r\n    mask: var(--gradient);\r\n}\r\n::-webkit-meter-even-less-good-value {\r\n    background: red;\r\n}\r\n::-webkit-meter-suboptimum-value {\r\n    background: linear-gradient(to right, red var(--size), orange 0);\r\n}\r\n::-webkit-meter-optimum-value {\r\n    background: linear-gradient(to right, red var(--size), orange 0 calc(2 * var(--size)), green 0);\r\n}<\/pre>\n<p>\u5982\u679c\u60f3\u8981\u6539\u53d8\u5f3a\u5ea6\u6d4b\u91cf\u6761\u5143\u7d20\u7684\u5bbd\u5ea6\uff0c\u53ea\u9700\u8981\u4fee\u6539CSS\u81ea\u5b9a\u4e49\u5c5e\u6027 <code>--size<\/code> \u7684\u503c\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<h4>\u773c\u89c1\u4e3a\u5b9e\uff0c\u6548\u679c\u4f53\u9a8c<\/h4>\n<p>\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/202111\/meter.html\" rel=\"noopener\" target=\"_blank\">meter\u5143\u7d20\u81ea\u5b9a\u4e49\u6548\u679c\u7eaf\u4eab\u7248demo<\/a><\/p>\n<p>\u8fdb\u884c\u6548\u679c\u4f53\u9a8c\u3002<\/p>\n<p>\u81f3\u6b64\uff0c\u6240\u6709\u76f8\u5173\u5b9e\u73b0\u7684\u4ecb\u7ecd\u90fd\u7ed3\u675f\u4e86\u3002<\/p>\n<h3>\u516d\u3001\u603b\u7ed3<\/h3>\n<p>\u5f53\u7136\uff0c\u6b63\u5982\u4e00\u5f00\u59cb\u6240\u63d0\u5230\u7684\uff0c<code>&lt;meter&gt;<\/code> \u5143\u7d20\u4e0d\u4ec5\u53ef\u4ee5\u7528\u6765\u8868\u793a\u5bc6\u7801\u5f3a\u5ea6\u3002\u5728 Web \u4e2d\uff0c\u6240\u6709\u4e0e\u4e08\u91cf\u3001\u6d4b\u91cf\u76f8\u5173\u7684\u573a\u666f\uff0c\u90fd\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u8fd9\u4e00\u4e2a HTML \u5143\u7d20\u3002<\/p>\n<p>\u6709\u4eba\u53ef\u80fd\u4f1a\u7ea0\u7ed3 IE \u6d4f\u89c8\u5668\u7684\u95ee\u9898\u3002<\/p>\n<p>\u6bd5\u7adf <code>&lt;meter&gt;<\/code> \u5143\u7d20\u7684\u517c\u5bb9\u6027\u662f\u8fd9\u6837\u5b50\u7684\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/2021-11-14_220936.png\" width=\"633\" height=\"229\" alt=\"meter \u5143\u7d20\u7684\u517c\u5bb9\u6027\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u4e00\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528polyfill\uff0c\u6211\u8fd9\u91cc\u627e\u4e86\u4e2a\u9879\u76ee\uff1a<a href=\"https:\/\/github.com\/fisker\/meter-polyfill\" rel=\"noopener\" target=\"_blank\">https:\/\/github.com\/fisker\/meter-polyfill<\/a><\/p>\n<p>\u8fd9\u4e2a\u9879\u76ee\u7684\u4f5c\u8005\u53ef\u80fd\u662f\u56fd\u4eba\uff0c\u56e0\u4e3a\u5934\u50cf\u770b\u8d77\u6765\u975e\u5e38\u719f\u6089\uff0c\u4e0d\u8fc7\u8fd9\u4e2a polyfill \u9879\u76ee\u6211\u81ea\u5df1\u6ca1\u8bd5\u8fc7\uff0c\u6240\u4ee5\u8d28\u91cf\u5982\u4f55\u5e76\u4e0d\u6e05\u695a\u3002<\/p>\n<p>\u4ece\u6211\u81ea\u5df1\u7684\u89d2\u5ea6\u8bb2\uff0c\u5982\u679c\u6211\u662f\u9047\u5230\u8fd9\u6837\u7684\u573a\u666f\uff0c\u6211\u4f1a\u8bf4\u670d\u4ea7\u54c1\u76f4\u63a5\u653e\u5f03 IE\u6d4f\u89c8\u5668\uff0c\u5c31\u4e0d\u7528\u641e\u4ec0\u4e48\u6240\u8c13\u7684\u5bc6\u7801\u5f3a\u5ea6\u4e86\uff0c\u672c\u6765\u8fd9\u79cd\u5bc6\u7801\u5f3a\u5ea6\u5c31\u662f\u9526\u4e0a\u6dfb\u82b1\u7684\u529f\u80fd\uff0c\u6ca1\u6709\u7684\u8bdd\uff0c\u4e5f\u4e0d\u5f71\u54cd\u529f\u80fd\u3002<\/p>\n<p>\u51b5\u4e14\u73b0\u5728 IE \u6d4f\u89c8\u5668\u5360\u6bd4\u5176\u5b9e\u975e\u5e38\u4f4e\u4e86\uff0c3%\u90fd\u4e0d\u5230\uff0c\u6211\u4e0d\u77e5\u9053\u5176\u4ed6\u516c\u53f8\u4ea7\u54c1\u600e\u6837\u7684\uff0c\u4ee5\u53ca\u6211\u4eec\u5f00\u53d1\u4ea7\u54c1\u603b\u662f\u8981\u9762\u5411\u672a\u6765\u7684\uff0c\u4f60\u4e0d\u80fd\u8bf4\u6211\u5f53\u4e0b\u8fd8\u6709\u4e00\u4e9b IE \u6d4f\u89c8\u5668\u7528\u6237\uff0c\u4f60\u5c31\u653e\u5f03\u4e86\u672a\u6765\uff0c\u60f3\u60f3\u770b\uff0c\u73b0\u5728\u9879\u76ee\u4e2d\u8fd8\u6709\u517c\u5bb9 IE8 \u6d4f\u89c8\u5668\u7684\u4ee3\u7801\uff0c\u662f\u4e0d\u662f\u60f3\u5410\u3002<\/p>\n<p>\u5f53\u7136\uff0c\u5982\u679c\u4ea7\u54c1\u662f\u4e2a\u76f4\u6e9c\u5b50\u8bf4\u670d\u4e0d\u901a\uff0c\u4ee5\u4e3a\u5de5\u7a0b\u5e08\u5c31\u662f\u60f3\u5077\u61d2\u3002<\/p>\n<p>\u90a3\u6211\u89c9\u5f97\u4e13\u95e8\u7ed9IE\u505a\u4e00\u4e2a\u7279\u6b8a\u7684\u5904\u7406\uff0c\u5176\u5b9e\u4e5f\u4e0d\u9700\u8981\u591a\u5927\u7684\u6210\u672c\uff0c\u56de\u5934\u54ea\u5929 IE \u55dd\u5c41\u4e86\u76f4\u63a5\u79fb\u9664\u5c31\u597d\u3002<\/p>\n<p>\u597d\uff0c\u5df4\u62c9\u5df4\u62c9\uff0c\u65ad\u65ad\u7eed\u7eed\uff0c\u6ca1\u60f3\u5230\u8bb2\u4e86\u8fd9\u4e48\u591a\uff0c\u8fd9\u7bc7\u6587\u7ae0\u7bc7\u5e45\u53c8\u94fa\u51fa\u6765\u4e86\uff0c\u6240\u4ee5\u5c31\u4e0d\u518d\u5570\u55e6\u4e86\u3002<\/p>\n<p>\u884c\u6587\u4e0d\u6613\uff0c\u6b22\u8fce\u5206\u4eab\uff0c\u611f\u8c22\u8f6c\u53d1\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/emtion\/emoji\/1f913.svg\" width=\"20\" height=\"20\" align=\"absmiddle\"><\/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=10188\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=10188<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u914d\u5408meter\u5143\u7d20\uff0c\u7eafCSS\u4e5f\u80fd\u5b9e\u73b03\u8272\u72b6\u6001\u5e26\u5f3a\u4e2d\u5f31\u63d0\u793a\u7684\u5bc6\u7801\u5f3a\u5ea6\u6548\u679c\uff0c\u6709\u57fa\u7840\u6709\u6df1\u5165\uff0c\u672c\u6587\u53ef\u4ee5\u5b66\u5230\u7684\u4e1c\u897f\u633a\u591a\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202111\/pwd-ui3.gif\" width=\"411\" height=\"49\" alt=\"\u6700\u7ec8\u6e10\u53d8\u6587\u5b57\u6548\u679c\"><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,1097],"tags":[364,9,37,614,1078,830,1797,138,823],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10188"}],"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=10188"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10188\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=10188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=10188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=10188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}