{"id":4905,"date":"2016-03-19T13:21:27","date_gmt":"2016-03-19T05:21:27","guid":{"rendered":"https:\/\/sdeno.com\/?p=4905"},"modified":"2016-03-26T22:32:16","modified_gmt":"2016-03-26T14:32:16","slug":"%e6%a3%80%e6%b5%8b%e6%b5%8f%e8%a7%88%e5%99%a8%e6%98%af%e5%90%a6%e5%85%bc%e5%ae%b9css3%e3%80%81html5%e6%9f%90%e4%b8%ad%e5%b1%9e%e6%80%a7-modernizr-js","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=4905","title":{"rendered":"\u68c0\u6d4b\u6d4f\u89c8\u5668\u662f\u5426\u517c\u5bb9css3\u3001HTML5\u67d0\u79cd\u5c5e\u6027--Modernizr.js"},"content":{"rendered":"<p>\u5224\u65ad \u6d4f\u89c8\u5668 \u5224\u65ad \u68c0\u6d4b \u6d4f\u89c8\u5668 \u7248\u672c \u662f\u5426 \u517c\u5bb9 \u652f\u6301 CSS3 HTML5 \u5c5e\u6027<\/p>\n<p>HTML5 \u548c CSS3 \u7684\u5feb\u901f\u53d1\u5c55\uff0c\u7ed9\u6211\u4eec\u5e26\u6765\u4e86\u6781\u5927\u7684\u4fbf\u5229\uff0c\u6bd4\u5982\u4ece\u6b64\u518d\u4e5f\u4e0d\u7528\u82b1\u8d39\u5927\u91cf\u7684\u65f6\u95f4\u53ea\u662f\u4e3a\u4e86\u8bbe\u8ba1\u4e00\u4e2a\u5706\u89d2\u7684\u6548\u679c\u3002<\/p>\n<p>\u4f46\u662f\uff01\u6211\u4eec\u4e0d\u80fd\u50cf\u63a7\u5236\u673a\u5668\u4e00\u6837\u6765\u63a7\u5236\u6240\u6709\u7684\u4eba\u90fd\u4e00\u591c\u4e4b\u95f4\u5347\u7ea7\u5230\u73b0\u4ee3\u6d4f\u89c8\u5668\uff0c\u56e0\u4e3a\u90a3\u4e9b \u4e0d\u591f\u73b0\u4ee3\u7684\u6d4f\u89c8\u5668 \u8bde\u751f\u4e4b\u65f6\uff0cHTML5\u548cCSS3\u5c1a\u672a\u88ab\u6b63\u5f0f\u63a8\u51fa\u3002<\/p>\n<p>\u4e8e\u662f\uff0c\u6211\u4eec\u7684\u95ee\u9898\u6765\u4e86\uff1a\u9488\u5bf9\u90a3\u4e9b\u4e0d\u652f\u6301\u65b0\u7279\u6027\u7684\u6d4f\u89c8\u5668\u800c\u8a00\uff0c\u6211\u4eec\u662f\u76f4\u63a5\u653e\u5f03\u8fd9\u4e9b\u7528\u6237\u7fa4\u5462\uff0c\u8fd8\u662f\u76f4\u63a5\u4e0d\u7528\u8fd9\u4e9b\u65b0\u7279\u6027\uff0c\u8001\u8001\u5b9e\u5b9e\u7684\u7528\u56fe\u7247\u62fc\u51fa\u5706\u89d2\u7684\u7279\u6548\uff1f<\/p>\n<p>\u6211\u60f3\uff0c\u7b54\u6848\u662f\u663e\u800c\u6613\u89c1\u7684\u3002\u6211\u4eec\u4e0d\u80fd\u653e\u5f03\u90a3\u4e9b\u56e0\u4e3a\u8fd9\u6837\u90a3\u6837\u7684\u539f\u56e0\u6ca1\u6cd5\u5347\u7ea7\u4ed6\u4eec\u7684\u6d4f\u89c8\u5668\u7528\u6237\uff0c\u4f46\u4e5f\u4e0d\u80fd\u59d4\u5c48\u4e86\u81ea\u5df1\uff0c\u4e0d\u80fd\u7528\u8fd9\u4e9b\u5f88\u9177\u7684\u6280\u672f\u6765\u5199\u4ee3\u7801\u3002<\/p>\n<p>\u6240\u4ee5\u6211\u4eec\u6839\u636e\u6d4f\u89c8\u5668\u7684\u4e0d\u540c\u9009\u62e9\u76f8\u5e94\u7684\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u4e3e\u4f8b\u5b50\uff1a<\/p>\n<p>1\uff0c\u53bb\u7f51\u7ad9\uff1a<a href=\"https:\/\/modernizr.com\/download?setclasses\" target=\"_blank\">https:\/\/modernizr.com\/download?setclasses<\/a><\/p>\n<a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/03\/modernizr.png\"><figure class=\"mdx-lazyload-container\" style=\"max-width:759px\"><div style=\"padding-top:42.424242424242%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"759\" height=\"322\" class=\"alignnone size-full wp-image-4906 lazyload\" title=\"modernizr\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/03\/modernizr.png\" alt=\"modernizr\" data-srcset=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/03\/modernizr.png 759w, https:\/\/sdeno.com\/wp-content\/uploads\/2016\/03\/modernizr-300x127.png 300w\" sizes=\"auto, (max-width: 759px) 100vw, 759px\"><\/figure><\/a>\n<p>\u8fd9\u91cc\u6211\u4eec\u68c0\u6d4b\u6d4f\u89c8\u5668\u662f\u5426\u652f\u6301&lt;video&gt;\u8fd9\u4e2a\u89c6\u9891\u5c5e\u6027\uff0c\u6839\u636e\u4e0a\u9762\u7684\u56fe\u4e0b\u8f7d\u597d\u63d2\u4ef6\u540e\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>2,\u5c06\u63d2\u4ef6\u52a0\u8f7d\u5230\u6240\u6709\u63d2\u4ef6\u6700\u524d\u9762\u3002<\/p>\n<p>\u5982\u679c\u6d4f\u89c8\u5668\u652f\u6301&lt;video&gt;\u5219\u4f1a\u5728&lt;html&gt;\u4e0a\u663e\u793a&lt;html class=&#8221; audio&#8221;&gt;\uff0c\u5982\u679c\u4e0d\u652f\u6301\u5219\u663e\u793a&lt;html class=&#8221;no- audio&#8221;&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>3,\u505a\u76f8\u5e94\u5904\u7406<\/p>\n<p>css\u505a\u76f8\u5e94\u5904\u7406<\/p>\n<pre>.no-audio .box { color: red; \/\/\u4e0d\u652f\u6301\u8fd0\u884c\u6b64\u6837\u5f0f}\r\n.audio .box { color: green; \/\/\u652f\u6301\u8fd0\u884c\u6b64\u6837\u5f0f}<\/pre>\n<p>&nbsp;<\/p>\n<p>js\u505a\u76f8\u5e94\u5904\u7406<\/p>\n<pre>if (Modernizr.audio) {\r\n \/\/ supported\u652f\u6301\u8fd0\u884c\u6b64\r\n} else {\r\n \/\/ not-supported\u4e0d\u652f\u6301\u8fd0\u884c\u6b64\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>html\u6807\u7b7eclass\u4e2d\u5982\u679c\u662f\u7c7b\u4f3cno-input-formtarget\u8fd9\u6837\u7684\uff0c\u5982\u679c\u8981\u5224\u65ad\u662f\u5426\u652f\u6301\u5c31\u4f7f\u7528<\/p>\n<pre>if (Modernizr.inputformtarget) {\r\n \/\/ input-formtarget\u652f\u6301\u8fd0\u884c\u6b64\r\n} else {\r\n \/\/ input-formtarget\u4e0d\u652f\u6301\u8fd0\u884c\u6b64\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u7531\u4e8eModernizr\u5e2e\u6211\u4eec\u5185\u7f6e\u4e86 html5shiv \u7c7b\u5e93\uff0c\u6240\u4ee5\u6211\u4eec\u5fc5\u987b\u5728 &lt;body&gt; \u52a0\u8f7d\u4e4b\u524d\u5f15\u7528\u8fd9\u4e2a\u7c7b\u5e93\u3002\u5f53\u7136\u4f60\u5982\u679c\u9488\u5bf9\u7684\u662fIE9+\u7684\u6d4f\u89c8\u5668\uff0c\u90a3\u4e48\u5927\u53ef\u4ee5\u5728\u9875\u9762\u5143\u7d20\u52a0\u8f7d\u5b8c\u540e\u518d\u5f15\u5165\uff0c\u4f46\u8fd9\u6837\u5c31\u4f1a\u6709 FOUC \u8fd9\u6837\u6781\u4e0d\u53cb\u597d\u7684\u6548\u679c\u51fa\u73b0\u3002<\/p>\n<p>\u6700\u540e\uff0c\u6211\u4eec\u9700\u8981\u5728 &lt;html&gt; \u6807\u7b7e\u4e2d\u52a0\u5165 no-js \u7c7b\uff0c\u4ee5\u514d\u6d4f\u89c8\u5668\u7981\u7528\u4e86JavaScript\u3002<\/p>\n<p>&nbsp;<\/p>\n<h3 style=\"font-weight: bold;\">Modernizr.load()<\/h3>\n<p>\u57fa\u4e8e\u00a0<a style=\"font-weight: bold; font-style: italic; color: #949494;\" href=\"http:\/\/yepnopejs.com\/\">YepNope.js<\/a>\u00a0\uff0cModernizr.load()\u6839\u636e\u4e00\u4e9b\u6761\u4ef6\u5224\u65ad\u6765\u52a8\u6001\u9009\u62e9\u52a0\u8f7dCSS\u548cJavaScript\uff0c\u8fd9\u65e0\u7591\u5bf9\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u8d44\u6e90\u52a0\u8f7d\u6709\u6781\u5927\u7684\u5e2e\u52a9\u3002<\/p>\n<p>\u4f60\u53ef\u4ee5\u5728\u8fd9\u91cc(\u00a0<a style=\"font-weight: bold; font-style: italic; color: #949494;\" href=\"https:\/\/github.com\/Modernizr\/Modernizr\/wiki\/HTML5-Cross-browser-Polyfills\">HTML5 Cross Browser Polyfills<\/a>\u00a0)\u627e\u5230\u51e0\u4e4e\u6240\u6709\u65b0\u7279\u6027\u7684fallback\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<pre class=\"prettyprint sql\">Modernizr.<span class=\"operator\"><span class=\"keyword\" style=\"font-weight: bold;\">load<\/span>(\r\n    test: Modernizr.webgl,\r\n    yep : <span class=\"string\" style=\"color: #dd1144;\">'three.js'<\/span>,\r\n    nope: <span class=\"string\" style=\"color: #dd1144;\">'jebgl.js'<\/span> \r\n);<\/span><\/pre>\n<p>\u5f53\u6d4f\u89c8\u5668\u652f\u6301WebGL\u7684\u65f6\u5019\uff0c\u5c31\u5f15\u5165\u00a0<a style=\"font-weight: bold; font-style: italic; color: #949494;\" href=\"http:\/\/threejs.org\/%E2%80%8E\">three.js<\/a>\u00a0\u8fd9\u4e2a\u7c7b\u5e93\u505a\u4e00\u4e9b3D\u6548\u679c\u3002\u6d4f\u89c8\u5668\u4e0d\u652f\u6301WebGL\u7684\u65f6\u5019\u53ef\u4ee5\u4f7f\u7528\u00a0<a style=\"font-weight: bold; font-style: italic; color: #949494;\" href=\"http:\/\/jebgl.com\/%E2%80%8E\">jebgl.js<\/a>\u00a0\u505a\u4e00\u4e9bfallback\u64cd\u4f5c\u3002<\/p>\n<p>\u8fd8\u6709\u4e00\u4e2a\u6bd4\u8f83\u9177\u7684\u4f8b\u5b50\u6765\u81ea\u5b98\u65b9\u6587\u6863\u3002\u6211\u4eec\u5728\u7528jQuery\u7c7b\u5e93\u7684\u65f6\u5019\uff0c\u901a\u5e38\u90fd\u662f\u8fd9\u79cd\u5199\u6cd5\uff1a<\/p>\n<pre class=\"prettyprint xml\"><span class=\"tag\" style=\"color: #000080;\">&lt;<span class=\"title\" style=\"color: #000080;\">script<\/span> <span class=\"attribute\" style=\"color: #008080;\">src<\/span>=<span class=\"value\" style=\"color: #dd1144;\">\"\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.7.1\/jquery.js\"<\/span>&gt;<\/span><span class=\"tag\" style=\"color: #000080;\">&lt;\/<span class=\"title\" style=\"color: #000080;\">script<\/span>&gt;<\/span>\r\n<span class=\"tag\" style=\"color: #000080;\">&lt;<span class=\"title\" style=\"color: #000080;\">script<\/span>&gt;<\/span><span class=\"javascript\">window.jQuery || document.write(<span class=\"string\" style=\"color: #dd1144;\">'&lt;script src=\"js\/libs\/jquery-1.7.1.min.js\"&gt;\\x3C\/script&gt;'<\/span>)<\/span><span class=\"tag\" style=\"color: #000080;\">&lt;\/<span class=\"title\" style=\"color: #000080;\">script<\/span>&gt;<\/span><\/pre>\n<p>\u73b0\u5728\u7528Modernizr.load()\u53ef\u4ee5\u8fd9\u4e48\u5199\uff1a<\/p>\n<pre class=\"prettyprint sql\">Modernizr.<span class=\"operator\"><span class=\"keyword\" style=\"font-weight: bold;\">load<\/span>([\r\n  {\r\n    <span class=\"keyword\" style=\"font-weight: bold;\">load<\/span>: <span class=\"string\" style=\"color: #dd1144;\">'\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.7.1\/jquery.js'<\/span>,\r\n    complete: function () {\r\n      if ( !window.jQuery ) {\r\n            Modernizr.<span class=\"keyword\" style=\"font-weight: bold;\">load<\/span>(<span class=\"string\" style=\"color: #dd1144;\">'js\/libs\/jquery-1.7.1.min.js'<\/span>);<\/span>\r\n      }\r\n    }\r\n  },\r\n  {\r\n    \/\/ This will wait for the fallback to <span class=\"operator\"><span class=\"keyword\" style=\"font-weight: bold;\">load<\/span> <span class=\"keyword\" style=\"font-weight: bold;\">and<\/span>\r\n    \/\/ <span class=\"keyword\" style=\"font-weight: bold;\">execute<\/span> if it needs <span class=\"keyword\" style=\"font-weight: bold;\">to<\/span>.\r\n    <span class=\"keyword\" style=\"font-weight: bold;\">load<\/span>: <span class=\"string\" style=\"color: #dd1144;\">'needs-jQuery.js'<\/span>\r\n  }\r\n]);<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p>\u6587\u7ae0\u6765\u81ea\uff1a<a href=\"http:\/\/www.tuicool.com\/articles\/UVnEVj\" target=\"_blank\">http:\/\/www.tuicool.com\/articles\/UVnEVj<\/a><\/p>\n<p>\u82f1\u6587\u4ecb\u7ecd\uff1a<a href=\"https:\/\/github.com\/Modernizr\/Modernizr\/wiki\/HTML5-Cross-browser-Polyfills\" target=\"_blank\">https:\/\/github.com\/Modernizr\/Modernizr\/wiki\/HTML5-Cross-browser-Polyfills<\/a><\/p>\n<p><a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/03\/modernizr-custom-.txt\">modernizr-custom.js\u4e0b\u8f7d<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5224\u65ad \u6d4f\u89c8\u5668 \u5224\u65ad \u68c0\u6d4b \u6d4f\u89c8\u5668 \u7248\u672c \u662f\u5426 \u517c\u5bb9 \u652f\u6301 CSS3 HTML5 \u5c5e\u6027 HTML5 \u548c CSS3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-4905","post","type-post","status-publish","format-standard","hentry","category-11"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/4905","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4905"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/4905\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}