{"id":5583,"date":"2016-08-08T23:49:01","date_gmt":"2016-08-08T15:49:01","guid":{"rendered":"http:\/\/www.zhangxinxu.com\/wordpress\/?p=5583"},"modified":"2019-12-11T18:54:30","modified_gmt":"2019-12-11T10:54:30","slug":"vw-viewport-responsive-layout-typography","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2016\/08\/vw-viewport-responsive-layout-typography\/","title":{"rendered":"\u57fa\u4e8evw\u7b49viewport\u89c6\u533a\u5355\u4f4d\u914d\u5408rem\u54cd\u5e94\u5f0f\u6392\u7248\u548c\u5e03\u5c40"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=5583\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=5583<\/a><br \/>\n\u672c\u6587\u5168\u6587\u8f6c\u8f7d\u9700\u8d2d\u4e70\u7248\u6743\uff0c\u6458\u8981\u5f15\u6d41\u5219\u514d\u8d39\uff0c\u5177\u4f53<a href=\"https:\/\/www.zhangxinxu.com\/sp\/copyright.html\" target=\"_blank\">\u53c2\u89c1\u8fd9\u91cc<\/a><\/p>\n<h3>\u4e00\u3001\u4ec0\u4e48\u662f\u89c6\u533a\u76f8\u5bf9\u5355\u4f4d\uff1f<\/h3>\n<p>\u5c31\u662f\u76f8\u5bf9\u4e8e\u6d4f\u89c8\u5668viewport\u5c3a\u5bf8\u7684\u5355\u4f4d\uff0c\u5177\u4f53\u5305\u62ec\u4e0b\u97624\u4e2a\uff1a<\/p>\n<ul>\n<li>vw &#8211; \u89c6\u533a\u5bbd\u5ea6\u767e\u5206\u503c<\/li>\n<li>vh &#8211; \u89c6\u533a\u9ad8\u5ea6\u767e\u5206\u503c<\/li>\n<li>vmin &#8211; vw\u6216vh\uff0c\u53d6\u5c0f\u7684\u90a3\u4e2a<\/li>\n<li>vmax &#8211; vw\u6216vh\uff0c\u53d6\u5927\u7684\u90a3\u4e2a<\/li>\n<\/ul>\n<p>\u81f3\u4e8e\u66f4\u5177\u4f53\u7684\u5185\u5bb9\uff0c\u6211\u5c31\u4e0d\u5c55\u5f00\u4e86\uff0c\u56e0\u4e3a\u6211\u53d1\u73b0\u5df2\u7ecf\u6709\u4e00\u4e2a\u5f88\u5389\u5bb3\u7684\u4eba\u5bf9\u8fd9\u4e9b\u5355\u4f4d\u4f5c\u4e3a\u5f88\u8be6\u7ec6\u7684\u4ecb\u7ecd\u4e86\uff0c\u662f\u8d85\u8be6\u7ec6\uff0c\u8fd9\u4e2a\u4eba\u8d85\u80fd\u5199\u3002\u800c\u4e14\u4e00\u770b\u53d1\u8868\u65e5\u671f\uff0c2012\u5e749\u6708\uff0c\u6211\u52d2\u4e2a\u64e6\uff0c\u8fd9\u4e0d\u662f\u4e0a\u5c4a\u4f26\u6566\u5965\u8fd0\u4f1a\u7684\u65f6\u5019\u561b\uff0c\u8db3\u8db3\u67094\u5e74\u4e86\u5440\uff0c\u4e5f\u592a\u524d\u6cbf\u4e86\u5427\uff0c\u90a3\u4e2a\u65f6\u5019\u7684\u6d4f\u89c8\u5668\u517c\u5bb9\u6027\u8fd8\u53ea\u662f\u8fd9\u5e45\u9e1f\u6837\u5b50\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\u89c6\u533a\u76f8\u5173\u5355\u4f4d\u517c\u5bb9\u6027\u88682012\u5e74\" title=\"\u89c6\u533a\u76f8\u5173\u5355\u4f4d\u517c\u5bb9\u6027\u8868\" width=\"514\" height=\"366\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/201209\/2012-09-23_161025.png\"><\/p>\n<p>\u597d\u4e1c\u897f\u5462\u662f\u8981\u5206\u4eab\u6ef4\uff0c<strong>\u8fd9\u7bc7\u6587\u7ae0\u5c31\u662f<\/strong>\uff1a\u201c<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=2636\">\u89c6\u533a\u76f8\u5173\u5355\u4f4dvw, vh..\u7b80\u4ecb\u4ee5\u53ca\u53ef\u5b9e\u9645\u5e94\u7528\u573a\u666f<\/a>\u201d\uff0c\u901f\u901f\u56f4\u89c2\uff0c\u5c31\u7b97\u4e0d\u5b66\u77e5\u8bc6\uff0c\u4e5f\u770b\u611f\u53d7\u4e0b\u8fd9\u7bc7\u6587\u7ae0\u7684\u6c14\u573a\u3002<\/p>\n<p>\u5927\u5bb6\u6709\u6ca1\u6709\u53d1\u73b0\uff0c\u2026\u2026\u2026\u2026\u2026\u2026\u2026\u2026\uff0c\u8fd9\u4e2a\u5f88\u5389\u5bb3\u7684\u4eba\u539f\u6765\u5c31\u662f\u6211\u672c\u4eba\u2026\u2026  <img decoding=\"async\" src=\"https:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/28.gif\" align=\"absmiddle\"><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/201608\/zlian-sun.jpg\" width=\"150\" height=\"148\" alt=\"\u81ea\u604b\u81ea\u62cd\" class=\"alignnone\" \/><\/p>\n<p>4\u5e74\u65f6\u5149\uff0c\u7269\u662f\u4eba\u975e\uff0c<code>vw<\/code>\u5934\u4e0a\u7684\u8349\u4e5f\u8d8a\u6765\u8d8a\u7eff\u4e86\uff0c\u73b0\u5728\u7684\u517c\u5bb9\u6027\u5219\u662f\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/201608\/2016-08-08_215718.png\" width=\"664\" height=\"474\" alt=\"vw\u5355\u4f4d\u73b0\u5728\u7684\u517c\u5bb9\u6027\" class=\"alignnone\" \/><\/p>\n<p>\u786e\u5b9e\u7eff\u4e86\u5f88\u591a\uff0cAndroid 4.4\u5f00\u59cb\u652f\u6301\uff0c\u524d\u6bb5\u65f6\u95f4\u7ed9\u8001\u7239\u4e70\u7684\u534e\u4e3a\u673a\u5b50\u9ed8\u8ba4\u90fd\u662f5.*\u7248\u672c\uff0c\u770b\u4e0a\u53bb\uff0c<code>vw<\/code>\u5728\u79fb\u52a8\u7aef\u7684\u6625\u5929\u8981\u6765\u54c8~<\/p>\n<p>CSS3\u4e2d\u8fd8\u6709\u53e6\u5916\u4e00\u4e2a\u5355\u4f4d<code>rem<\/code>\uff0c\u4f30\u8ba1\u6709\u4e0d\u5c11\u5c0f\u4f19\u4f34\u8033\u95fb\u6216\u8005\u7528\u8fc7\uff0c\u4e3a\u4f55<code>rem<\/code>\u8981\u6bd4<code>vw<\/code>\u706b\u5462\uff0c\u56e0\u4e3a<code>rem<\/code>\u4eceAndroid 2.1\u7248\u672c\u5c31\u5f00\u59cb\u652f\u6301\u4e86\uff0c\u517c\u5bb9\u6027\u597d\u3002\u4e00\u65e6\u517c\u5bb9\u6027\u4e0d\u662f\u95ee\u9898\uff0c<code>vw<\/code>\u4e5f\u4f1a\u706b\u8d77\u6765\u7684\uff0c\u5c31\u8ddf\u859b\u4e4b\u8c26\u4e00\u6837\u3002<\/p>\n<h3>\u4e8c\u3001\u57fa\u4e8evw\u7684\u54cd\u5e94\u5f0f\u6392\u7248\u548c\u5e03\u5c40<\/h3>\n<p>\u4e00\u822c\u800c\u8a00\uff0c\u5c4f\u5e55\u8d8a\u5927\uff0c\u6211\u4eec\u5e0c\u671b\u6587\u5b57\u5927\u5c0f\u4e5f\u8d8a\u5927\uff0c\u5143\u7d20\u7684\u5c3a\u5bf8\u4e5f\u80fd\u7b49\u6bd4\u4f8b\u653e\u5927\uff0c\u5c24\u5176\u5728\u73b0\u5728\u7684\u7f51\u9875\u8bbe\u8ba1\u98ce\u683c\u4e2d\u3002<\/p>\n<p>\u5982\u679c\u8981\u5b9e\u73b0\u8fd9\u79cd\u5f39\u6027\u81ea\u9002\u5e94\u6548\u679c\uff0c\u76ee\u524d\u4e3b\u6d41\u7684\u5b9e\u73b0\u662f\u901a\u8fc7\u8bbe\u5b9a\u6839\u5143\u7d20\u7684<code>font-size<\/code>\u5927\u5c0f\uff0c\u5177\u4f53\u5143\u7d20\u6216\u6a21\u5757\u4f7f\u7528<code>rem<\/code>\u6216<code>em<\/code>\u5355\u4f4d\u6765\u5b9e\u73b0\u3002<\/p>\n<p>\u4e00\u79cd\u662f\u76f4\u63a5\u8bbe\u5b9a\u4e00\u4e2a\u4e34\u754c\u70b9\u5b57\u4f53\u5927\u5c0f\uff0c\u5982\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>html {\r\n    font-size: 16px;\r\n}\r\n@media screen and (min-width: 600px) {\r\n    html {\r\n        font-size: 18px;\r\n    }\r\n}\r\n@media screen and (min-width: 1000px) {\r\n    html {\r\n        font-size: 22px;\r\n    }\r\n}<\/pre>\n<\/div>\n<p>\u8fd8\u6709\u4e00\u79cd\u5c31\u662f\u4f7f\u7528JS\u5728resize\u6216\u8005\u5c4f\u5e55\u65cb\u8f6c\u7684\u65f6\u5019\uff0c\u52a8\u6001\u4fee\u6539root\u7684<code>font-size<\/code>\u5927\u5c0f\u3002<\/p>\n<p>\u524d\u9762\u4e00\u79cd\u57fa\u4e8e<code>@media<\/code>\u7684CSS\u5b9e\u73b0\u95ee\u9898\u5728\u4e8e\uff0c\u5185\u5bb9\u7684\u5f39\u6027\u81ea\u9002\u5e94\u53ea\u4f1a\u5728\u4e34\u754c\u70b9\u7684\u65f6\u5019\uff0c\u201cDuang\u201d\u53d8\u5316\u4e0b\uff0c\u4e8e\u662f\uff0c\u6211\u4eec\u6d4f\u89c8\u5668\u5c3a\u5bf8\u62c9\u4f38\u7684\u65f6\u5019\uff0c\u4f1a\u611f\u53d7\u5230\u7c7b\u4f3c\u201c\u5654\u5654\u5654\u201d\u5361\u58f3\u7684\u6548\u679c\uff0c\u611f\u89c9\u5c31\u50cf\u662f\u5403\u4e86\u542b\u7b11\u534a\u6b65\u766b\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/201608\/hanxiao-s.jpg\" width=\"150\" height=\"200\" alt=\"\u542b\u7b11\u534a\u6b65\u98a0\" class=\"alignnone\" \/><\/p>\n<p>\u4f7f\u7528JS\u7684\u95ee\u9898\u5728\u4e8e\u4ed6\u662fJS\uff0c\u8981\u4fdd\u8bc1\u52a0\u8f7d\u4f53\u9a8c\uff0c\u9700\u8981\u5934\u90e8\u5185\u8054\uff0c\u4e3a\u4e86\u4fdd\u8bc1\u5b9e\u65f6\u6027\uff0c\u9700\u8981\u591a\u4e2a\u6d4f\u89c8\u5668\u53d8\u5316\u4e8b\u4ef6\u76d1\u6d4b\uff0c\u7528\u6211\u7684\u53e3\u5934\u7985\u8bb2\u5c31\u662f\u201c\u663e\u5f97\u5570\u55e6\u201d\u3002<\/p>\n<p>\u90a3\u6709\u6ca1\u6709\u4e24\u5168\u5176\u7f8e\u7684\u65b9\u6cd5\u5462\uff1f<\/p>\n<p>\u6709\uff0c\u90a3\u5c31\u662f\u672c\u6587\u8981\u9686\u91cd\u8bf7\u51fa\u573a\u7684<code>vw<\/code>\uff0c\u914d\u5408CSS3 <code>calc<\/code>\u8ba1\u7b97\u5b9e\u73b0\u52a8\u6001\u5b57\u4f53\u5927\u5c0f\u6548\u679c\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u6211\u4eec\u5e0c\u671b\u6d4f\u89c8\u5668\u5bbd\u5ea6\u5728600px~1000px\u53d8\u5316\u7684\u65f6\u5019\uff0chtml\u6839\u5143\u7d20\u7684<code>font-size<\/code>\u5927\u5c0f\u662f18px~22px\u4e4b\u95f4\u5bf9\u5e94\u53d8\u5316\u7684\uff0c\u5219\u53ef\u4ee5\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>html { font-size: calc(18px + 4 * (100vw - 600px) \/ 400); }<\/pre>\n<\/div>\n<p>\u5f53\u89c6\u533a\u5bbd\u5ea6\u662f<code>600px<\/code>\u7684\u65f6\u5019\uff0c<code>100vw<\/code>\u5c31\u7b49\u4e8e<code>600px<\/code>\uff0c\u4e8e\u662f\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>18px + 4 * (100vw - 600px) \/ 400\r\n\u2193\r\n18px + 4 * (600px - 600px) \/ 400\r\n\u2193\r\n18px<\/pre>\n<\/div>\n<p>\u5f53\u89c6\u533a\u5bbd\u5ea6\u662f<code>1000px<\/code>\u7684\u65f6\u5019\uff0c<code>100vw<\/code>\u5c31\u7b49\u4e8e<code>1000px<\/code>\uff0c\u4e8e\u662f\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>18px + 4 * (100vw - 600px) \/ 400\r\n\u2193\r\n18px + 4 * (1000px - 600px) \/ 400\r\n\u2193\r\n18px + 4px\r\n\u2193\r\n22px<\/pre>\n<\/div>\n<p>\u4e8e\u662f\uff0c\u7406\u8bba\u4e0a\uff0c\u4e00\u4e2a18px~22px\u5b57\u4f53\u5927\u5c0f\u52a8\u6001\u5339\u914d\u7684\u5e03\u5c40\u57fa\u7840\u5c31\u5efa\u597d\u4e86\u3002<\/p>\n<p>\u4e00\u822c\u51fa\u73b0\u201c\u7406\u8bba\u4e0a\u201d\u8fd9\u4e09\u4e2a\u5b57\uff0c\u5c31\u8bf4\u660e\u6211\u8981\u201c\u653e\u5751\u201d\u4e86\uff0c\u5927\u5bb6\u95ea\u5f00~~<\/p>\n<p>\u6b64\u201c\u5751\u201d\u5c31\u662f\u82f9\u679c\u7cfb\u7edf\u7684Safari\u6d4f\u89c8\u5668\u4e0d\u8ba4\u8bc6\u4e0a\u9762\u7684\u5c5e\u6027\u503c\uff08\u5982\u4e0b\u622a\u56fe\uff09\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/201608\/safari-not-s.png\" width=\"346\" height=\"163\" class=\"alignnone\" \/><\/p>\n<p>\u5c31Safari\u4e0d\u884c\uff0cwindow\u4e0b\u7684\u6240\u6709\u6d4f\u89c8\u5668\uff0c\u5305\u62ecIE\uff0c\u4ee5\u53camac\u4e0b\u7684Chrome\u7b49\u6d4f\u89c8\u5668\u90fd\u662f\u53ef\u4ee5\u6b63\u786e\u89e3\u6790\u7684\u3002<\/p>\n<p>\u6211\u8fd9\u7bc7\u6587\u7ae0\u7684\u524d\u4e00\u7bc7\u6587\u7ae0\u201c<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2016\/08\/safari-3d-transform-z-index\/\">Safari 3D transform\u53d8\u6362z-index\u5c42\u7ea7\u6e32\u67d3\u5f02\u5e38\u7684\u7814\u7a76<\/a>\u201d\u5c31\u662f\u5410\u69fd\u201cSafari\u662f\u65b0\u65f6\u4ee3\u7684IE6\u201d\u6765\u7740\uff0c\u6ca1\u60f3\u5230\u4e00\u65e5\u4e0d\u89c1\uff0c\u8fd9\u201c\u65b0\u65f6\u4ee3IE6\u201d\u7684\u540d\u58f0\u662f\u5750\u7684\u8d8a\u6765\u8d8a\u592f\u5b9e\u4e86\u54c8\uff01<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/201608\/xiaoku.gif\" width=\"22\" height=\"22\" align=\"absmiddle\" \/><\/p>\n<p>\u597d\u5728\uff0c\u6211\u4eec\u8fd8\u662f\u6709\u529e\u6cd5\u66f2\u7ebf\u6551\u56fd\u7684\u3002\u90a3\u5c31\u662f\uff0c\u6211\u4eec\u57fa\u7840\u5b57\u4f53\u5927\u5c0f\u4e0d\u4f7f\u7528\u50cf\u7d20\u5355\u4f4d\uff0c\u4f7f\u7528\u767e\u5206\u6bd4\u5355\u4f4d\u5373\u53ef\uff0c\u5982\u4e0b\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>html { font-size: calc(<span style=\"color:#cd0000;\">112.5%<\/span> + 4 * (100vw - 600px) \/ 400); }<\/pre>\n<\/div>\n<p>\u8fd9\u4e2a\u5305\u62ecSafari\u5728\u5185\u7684\u6d4f\u89c8\u5668\uff0c\u90fd\u80fd\u591f\u6309\u7167\u6211\u4eec\u7684\u9884\u671f\u8ba1\u7b97<code>font-size<\/code>\u5927\u5c0f\u4e86\uff0c\u4e8e\u662f\uff0c\u6211\u4eec\u4e00\u756a\u5012\u817e\uff0c\u5c31\u6709\u4e86\u5982\u4e0b\u7684\u54cd\u5e94\u5f0f\u8bbe\u7f6e\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>html {\r\n    <span style=\"color:green;\">\/* iPhone6\u7684375px\u5c3a\u5bf8\u4f5c\u4e3a16px\u57fa\u51c6\uff0c600px\u6b63\u597d18px\u5927\u5c0f *\/<\/span>\r\n    font-size: calc(100% + 2 * (100vw - 375px) \/ 225);\r\n}\r\n@media screen and (min-width: 600px) {\r\n    html {\r\n        <span style=\"color:green;\">\/* 600px-1000px\u6bcf100\u50cf\u7d20\u5bbd\u5b57\u4f53\u589e\u52a01px(18px-22px) *\/<\/span>\r\n        font-size: calc(112.5% + 4 * (100vw - 600px) \/ 400);\r\n    }\r\n}\r\n@media screen and (min-width: 1000px) {\r\n    html {\r\n        <span style=\"color:green;\">\/* 1000px\u5f80\u540e\u662f\u6bcf100\u50cf\u7d200.5px\u589e\u52a0 *\/<\/span>\r\n        font-size: calc(137.5% + 5 * (100vw - 1000px) \/ 1000);\r\n    }\r\n}<\/pre>\n<\/div>\n<p>\u6709\u4e2a\u52a8\u6001\u7684\u6839\u5b57\u4f53\u5927\u5c0f\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528<code>rem<\/code>\u6216<code>em<\/code>\u8fd9\u4e9b\u76f8\u5bf9\u5355\u4f4d\uff0c\u6765\u8ba9\u6211\u4eec\u7684\u9875\u9762\u6392\u7248\u548c\u5e03\u5c40\u66f4\u5bcc\u6709\u5f39\u6027\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/201608\/vw-layout-typography.html\" target=\"_blank\">\u57fa\u4e8evw\u7684\u5f39\u6027\u5e03\u5c40\u5c0f\u6f14\u793a\u5c0fdemo<\/a><\/p>\n<p>\u7ed3\u679c\u5728\u5927\u5c3a\u5bf8\u4e0b\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/201608\/2016-08-08_232219.png\" width=\"503\" height=\"236\" alt=\"\u5927\u5c3a\u5bf8\u4e0b\u622a\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u5c0f\u5c3a\u5bf8\u4e0b\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/201608\/2016-08-08_231913.png\" width=\"302\" height=\"172\" alt=\"\u5c0f\u5c3a\u5bf8\u4e0b\" class=\"alignnone\" \/><\/p>\n<p>\u5bf9\u6bd4\u4f1a\u53d1\u73b0\uff0c\u6587\u5b57\u7684\u5927\u5c0f\u548c\u56fe\u7247\u7684\u5927\u5c0f\u90fd\u660e\u663e\u4e0d\u4e00\u6837\u4e86\uff0c\u4f46\u662f\uff0c\u6700\u7ec8\u7ed9\u4eba\u7684\u6392\u7248\u7684\u611f\u89c9\u5374\u6ca1\u6709\u4ec0\u4e48\u4e0d\u8212\u670d\u7684\uff0c\u56e0\u4e3a\uff0c\u4f60\u4ed4\u7ec6\u770b\uff0c\u5c31\u4f1a\u53d1\u73b0\uff0c\u867d\u7136\u5b57\u53f7\u5dee\u522b\u5f88\u5927\uff0c\u4f46\u662f\u6587\u5b57\u7684\u6362\u884c\u4f4d\u7f6e\u5c45\u7136\u90fd\u662f\u4e00\u6a21\u4e00\u6837\u7684\uff0c\u8fd9\u6d3b\u8131\u8131\u7b49\u6bd4\u4f8b\u7f29\u653e\u7684\u5373\u89c6\u611f\u3002\u4f60\u8bf4\uff0c\u8fd9\u4e48\u6d12\u8131\u7684\u6548\u679c\uff0c\u4ec0\u4e48\u624b\u673a\u5404\u79cd\u5206\u8fa8\u7387\u9002\u914d\u8fd8\u662f\u95ee\u9898\u5417\uff1f\u662f\u95ee\u9898\u5417\uff1f<\/p>\n<p>\u5bf9\u5427\uff0c\u76f4\u63a5\u53d8\u6210\u4e86\u6bdb\u6bdb\u96e8\uff0c\u51e0\u884cCSS\uff0c\u5168\u90e8\u641e\u5b9a\uff01\u5982\u679c\u4f60\u8db3\u591f\u61d2\uff0c\u751a\u81f3\u53ef\u4ee5\u672c\u6587\u7684CSS\u4ee3\u7801\u76f4\u63a5copy\u5230\u81ea\u5df1\u9879\u76ee\u4e2d\u7528\uff0c\u6ce8\u91ca\u90fd\u4e0d\u9700\u8981\u6539\uff0c\u4e5f\u662f\u53ef\u4ee5\u7684\uff01<\/p>\n<p>\u8fd9\u4e48\u4f4e\u7684\u6210\u672c\uff0c\u8fd9\u4e48\u597d\u7684\u4f53\u9a8c\uff0c\u8fd8\u4e0d\u8d76\u5feb\u5728\u81ea\u5df1\u7684\u9879\u76ee\u91cc\u8bd5\u8bd5\uff1f<img decoding=\"async\" src=\"https:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/101.gif\" align=\"absmiddle\"><\/p>\n<p><strong>\u66f4\u65b0\u4e8e2017\u5e742\u67088\u65e5<\/strong><br \/>\n\u7ecf\u8fc7\u5927\u578b\u9879\u76ee\u5b9e\u8df5\uff0c\u4e0b\u9762\u8fd9\u6bb5CSS\u662f\u6700\u597d\u7684\u57fa\u4e8e<code>rem<\/code>\u548c<code>vw<\/code>\u548c<code>calc<\/code>\u5b9e\u8df5\u4ee3\u7801\uff1a<\/p>\n<pre>html {\r\n    font-size: 16px;\r\n}\r\n\r\n@media screen and (min-width: 375px) {\r\n    html {\r\n        <span style=\"color:green;\">\/* iPhone6\u7684375px\u5c3a\u5bf8\u4f5c\u4e3a16px\u57fa\u51c6\uff0c414px\u6b63\u597d18px\u5927\u5c0f, 600 20px *\/<\/span>\r\n        font-size: calc(100% + 2 * (100vw - 375px) \/ 39);\r\n        font-size: calc(16px + 2 * (100vw - 375px) \/ 39);\r\n    }\r\n}\r\n@media screen and (min-width: 414px) {\r\n    html {\r\n        <span style=\"color:green;\">\/* 414px-1000px\u6bcf100\u50cf\u7d20\u5bbd\u5b57\u4f53\u589e\u52a01px(18px-22px) *\/<\/span>\r\n        font-size: calc(112.5% + 4 * (100vw - 414px) \/ 586);\r\n        font-size: calc(18px + 4 * (100vw - 414px) \/ 586);\r\n    }\r\n}\r\n@media screen and (min-width: 600px) {\r\n    html {\r\n        <span style=\"color:green;\">\/* 600px-1000px\u6bcf100\u50cf\u7d20\u5bbd\u5b57\u4f53\u589e\u52a01px(20px-24px) *\/<\/span>\r\n        font-size: calc(125% + 4 * (100vw - 600px) \/ 400);\r\n        font-size: calc(20px + 4 * (100vw - 600px) \/ 400);\r\n    }\r\n}\r\n@media screen and (min-width: 1000px) {\r\n    html {\r\n        <span style=\"color:green;\">\/* 1000px\u5f80\u540e\u662f\u6bcf100\u50cf\u7d200.5px\u589e\u52a0 *\/<\/span>\r\n        font-size: calc(137.5% + 6 * (100vw - 1000px) \/ 1000);\r\n        font-size: calc(22px + 6 * (100vw - 1000px) \/ 1000);\r\n    }\r\n}<\/pre>\n<p>\u7136\u540e\uff0c\u5c31\u53ef\u4ee5\u6109\u5feb\u5730\u4f7f\u7528<code>rem<\/code>\u5355\u4f4d\u7528\u6765\u6392\u7248\u548c\u5e03\u5c40\u5566\uff01<\/p>\n<h3>\u4e09\u3001\u7ed3\u675f\u8bed<\/h3>\n<p>\u5bf9\u4e8e\u5927\u5382\uff0cAndroid4.4\u4e4b\u524d\u7684\u7248\u672c\uff0c\u76ee\u524d\u6015\u662f\u8fd8\u662f\u8981\u517c\u987e\u7684\uff0c\u600e\u4e48\u529e\uff1f\u6211\u89c9\u5f97\u6ca1\u6709\u5fc5\u8981\u4e3a\u4e86\u4e00\u4e2a\u8001\u59aa\u800c\u653e\u5f03\u6574\u4e2a\u540e\u5bab\uff0c\u5bf9\u4e8e\u7edd\u5927\u90e8\u5206\u8bbe\u5907\uff0c\u6211\u4eec\u8fd8\u662f<code>vw<\/code> + <code>calc<\/code>\u54d7\u5566\u5566\u5730\u8d70\u8d77\uff0c\u8001\u7684\u8bbe\u5907\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee5\u524dJS\u7684\u7b56\u7565\uff0c\u6253\u4e2a\u811a\u672c\u8865\u4e01\uff0c\u4f30\u8ba1\u5341\u6765\u884c\u4ee3\u7801\uff0c\u6548\u679c\u90fd\u662f\u4e00\u6837\u7684\uff0cCSS\u4ee3\u7801\u4e5f\u5b8c\u5168\u590d\u7528\uff0c\u4e00\u70b9\u90fd\u6ca1\u5fc5\u8981\u7279\u5f02\u5904\u7406\uff0c\u56e0\u4e3a\u8001\u673a\u5b50\u4e0d\u8ba4\u8bc6<code>vw<\/code>\uff0c\u6240\u4ee5\u5b8c\u5168\u6ca1\u5fc5\u8981\u62c5\u5fc3\u65b0\u8001\u51b2\u7a81\u8fd9\u6837\u7684\u95ee\u9898\u3002<\/p>\n<p>\u5f53\u7136\uff0c\u6211\u81ea\u5df1\u76ee\u524d\u4e5f\u6ca1\u5728\u6b63\u5f0f\u7684to C\u9879\u76ee\u4e2d\u5b9e\u8df5\u8fc7\uff0c\u6240\u4ee5\uff0c\u6216\u8bb8\u8fd8\u6709\u5176\u4ed6\u5751\u4ec0\u4e48\u7684\uff0cAndroid\u8bbe\u5907\u90a3\u4e48\u591a\uff0c\u8c01\u77e5\u9053\u54ea\u4e2a\u673a\u5b50\u7684\u6d4f\u89c8\u5668\u7a81\u7136\u5c31\u62bd\u98ce\u4e86\u5462\uff01<\/p>\n<p>\u4f46\u662f\uff0c\u8fd9\u5e76\u4e0d\u59a8\u788d\u6211\u5927\u80c6\u9884\u6d4b\uff1a\u518d\u8fc71~2\u5e74\uff0c\u57fa\u4e8e<code>vw<\/code>\u5e03\u5c40\u7684\u5404\u79cd\u6587\u7ae0\u3001\u5404\u79cd\u4e8b\u4ef6\u6848\u4f8b\u5c31\u4f1a\u96e8\u540e\u6625\u7b0b\u822c\u51fa\u73b0\u2026\u2026<\/p>\n<p>\u597d\u4e86\uff0c\u597d\u50cf\u6ca1\u6709\u4ec0\u4e48\u5176\u4ed6\u8981\u8bf4\u7684\u4e86\u3002<\/p>\n<p>\u611f\u8c22\u9605\u8bfb\uff0c\u6b22\u8fce\u4ea4\u6d41\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/14.gif\" align=\"absmiddle\"><\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u5c0a\u91cd\u8f9b\u52e4\u52b3\u52a8\uff0c\u53ef\u4ee5\u514d\u8d39\u6458\u8981\u3001\u63a8\u8350\u6216\u805a\u5408\uff0c\u4f46\u5b8c\u6574\u8f6c\u8f7d\u9700\u4ed8\u8d39\u8d2d\u4e70\u7248\u6743\uff0c\u8be6\u89c1<a href=\"https:\/\/www.zhangxinxu.com\/sp\/copyright.html\" target=\"_blank\">\u8f6c\u8f7d\u534f\u8bae\u58f0\u660e<\/a><br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=5583\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=5583<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u79fb\u52a8\u7aef\u7f51\u9875\u9002\u914d\u6700\u4f73\u5b9e\u8df5\u6307\u5357\uff0c\u57fa\u4e8erem\u548cvw\uff0c\u914d\u5408calc\u8ba1\u7b97\uff0c\u5143\u7d20\u5c3a\u5bf8\u8ddf\u968f\u6839\u5143\u7d20\u7684font-size\u5927\u5c0f\u52a8\u6001\u5316\u667a\u80fd\u5316\uff0c\u53ef\u4ee5\u8ba9\u6211\u4eec\u7684\u5e03\u5c40\u771f\u6b63\u610f\u4e49\u9002\u914d\u4e8e\u5404\u79cd\u8bbe\u5907\u5c3a\u5bf8\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":[971,63,1076,941,752,948,231,1530,1075,1529],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/5583"}],"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=5583"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/5583\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=5583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=5583"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=5583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}