{"id":2005,"date":"2018-11-09T17:31:10","date_gmt":"2018-11-09T09:31:10","guid":{"rendered":"https:\/\/www.baishitou.cn\/?p=2005"},"modified":"2018-11-09T19:40:50","modified_gmt":"2018-11-09T11:40:50","slug":"media-screen%e5%ae%9e%e7%8e%b0%e7%bd%91%e9%a1%b5%e5%b8%83%e5%b1%80%e7%9a%84%e8%87%aa%e9%80%82%e5%ba%94","status":"publish","type":"post","link":"https:\/\/www.baishitou.cn\/2005.html","title":{"rendered":"@media screen\u5b9e\u73b0\u7f51\u9875\u5e03\u5c40\u7684\u81ea\u9002\u5e94"},"content":{"rendered":"
\u65e0\u9700\u63d2\u4ef6\u548c\u624b\u673a\u4e3b\u9898,\u5bf9\u79fb\u52a8\u8bbe\u5907\u53cb\u597d,\u80fd\u591f\u9002\u5e94\u5404\u79cd\u7a97\u53e3\u5927\u5c0f\u3002\u53ea\u9700\u5728CSS\u4e2d\u6dfb\u52a0@media screen\u5c5e\u6027,\u6839\u636e\u6d4f\u89c8\u5668\u5bbd\u5ea6\u5224\u65ad\u5e76\u8f93\u51fa\u4e0d\u540c\u7684\u957f\u5bbd\u503c<\/span><\/p>\n \u9996\u5148\u6211\u4eec\u5728\u4f7f\u7528Media\u7684\u65f6\u5019\u9700\u8981\u5148\u8bbe\u7f6e\u4e0b\u9762\u8fd9\u6bb5\u4ee3\u7801\uff0c\u6765\u517c\u5bb9\u79fb\u52a8\u8bbe\u5907\u7684\u5c55\u793a\u6548\u679c\uff1a<\/p>\n \u8fd9\u6bb5\u4ee3\u7801\u7684\u51e0\u4e2a\u53c2\u6570\u89e3\u91ca\uff1a<\/p>\n \u56e0\u4e3aIE8\u65e2\u4e0d\u652f\u6301HTML5\u4e5f\u4e0d\u652f\u6301CSS3 Media\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u52a0\u8f7d\u4e24\u4e2aJS\u6587\u4ef6\uff0c\u6765\u4fdd\u8bc1\u6211\u4eec\u7684\u4ee3\u7801\u5b9e\u73b0\u517c\u5bb9\u6548\u679c\uff1a<\/p>\n \u73b0\u5728\u6709\u5f88\u591a\u4eba\u7684IE\u6d4f\u89c8\u5668\u90fd\u5347\u7ea7\u5230IE9\u4ee5\u4e0a\u4e86\uff0c\u6240\u4ee5\u8fd9\u4e2a\u65f6\u5019\u5c31\u6709\u53c8\u5f88\u591a\u8be1\u5f02\u7684\u4e8b\u60c5\u53d1\u751f\u4e86\uff0c\u4f8b\u5982\u73b0\u5728\u662fIE9\u7684\u6d4f\u89c8\u5668\uff0c\u4f46\u662f\u6d4f\u89c8\u5668\u7684\u6587\u6863\u6a21\u5f0f\u5374\u662fIE8:<\/p>\n \u4e3a\u4e86\u9632\u6b62\u8fd9\u79cd\u60c5\u51b5\uff0c\u6211\u4eec\u9700\u8981\u4e0b\u9762\u8fd9\u6bb5\u4ee3\u7801\u6765\u8ba9IE\u7684\u6587\u6863\u6a21\u5f0f\u6c38\u8fdc\u90fd\u662f\u6700\u65b0\u7684\uff1a<\/p>\n \uff08\u5982\u679c\u60f3\u4f7f\u7528\u56fa\u5b9a\u7684IE\u7248\u672c\uff0c\u53ef\u5199\u6210\uff1a<\/p>\n \u4e0d\u8fc7\u6211\u6700\u8fd1\u53c8\u53d1\u73b0\u4e86\u4e00\u4e2a\u66f4\u7ed9\u529b\u7684\u5199\u6cd5\uff1a<\/p>\n \u600e\u4e48\u8fd9\u6bb5\u4ee3\u7801\u540e\u9762\u52a0\u4e86\u4e00\u4e2achrome=1\uff0c\u8fd9\u4e2aGoogle Chrome Frame\uff08\u8c37\u6b4c\u5185\u5d4c\u6d4f\u89c8\u5668\u6846\u67b6GCF\uff09\uff0c\u5982\u679c\u6709\u7684\u7528\u6237\u7535\u8111\u91cc\u9762\u88c5\u4e86\u8fd9\u4e2achrome\u7684\u63d2\u4ef6\uff0c\u5c31\u53ef\u4ee5\u8ba9\u7535\u8111\u91cc\u9762\u7684IE\u4e0d\u7ba1\u662f\u54ea\u4e2a\u7248\u672c\u7684\u90fd\u53ef\u4ee5\u4f7f\u7528Webkit\u5f15\u64ce\u53caV8\u5f15\u64ce\u8fdb\u884c\u6392\u7248\u53ca\u8fd0\u7b97\uff0c\u65e0\u6bd4\u7ed9\u529b\uff0c\u4e0d\u8fc7\u5982\u679c\u7528\u6237\u6ca1\u88c5\u8fd9\u4e2a\u63d2\u4ef6\uff0c\u90a3\u8fd9\u6bb5\u4ee3\u7801\u5c31\u4f1a\u8ba9IE\u4ee5\u6700\u9ad8\u7684\u6587\u6863\u6a21\u5f0f\u5c55\u73b0\u6548\u679c\u3002\u8fd9\u6bb5\u4ee3\u7801\u6211\u8fd8\u662f\u5efa\u8bae\u4f60\u4eec\u7528\u4e0a\uff0c\u4e0d\u8fc7\u4e0d\u7528\u4e5f\u662f\u53ef\u4ee5\u7684\u3002<\/p>\n<\/div>\n<\/div>\n <\/p>\n \u6211\u4eec\u5148\u6765\u770b\u4e0b\u4e0b\u9762\u8fd9\u6bb5\u4ee3\u7801\uff0c\u4f30\u8ba1\u5f88\u591a\u4eba\u5728\u54cd\u5e94\u5f0f\u7684\u7f51\u7ad9CSS\u5f88\u7ecf\u5e38\u770b\u5230\u7c7b\u4f3c\u4e0b\u9762\u7684\u8fd9\u6bb5\u4ee3\u7801\uff1a<\/p>\n <\/p>\n \u8fd9\u4e2a\u5e94\u8be5\u7b97\u662f\u4e00\u4e2amedia\u7684\u4e00\u4e2a\u6807\u51c6\u5199\u6cd5\uff0c\u4e0a\u9762\u8fd9\u6bb5CSS\u4ee3\u7801\u610f\u601d\u662f\uff1a\u5f53\u9875\u9762\u5c0f\u4e8e960px\u7684\u65f6\u5019\u6267\u884c\u5b83\u4e0b\u9762\u7684CSS.\u8fd9\u4e2a\u5e94\u8be5\u6ca1\u6709\u592a\u5927\u7591\u95ee\u3002<\/p>\n <\/p>\n \u5e94\u8be5\u6709\u4eba\u4f1a\u53d1\u73b0\u4e0a\u9762\u8fd9\u6bb5\u4ee3\u7801\u91cc\u9762\u6709\u4e2ascreen\uff0c\u4ed6\u7684\u610f\u601d\u662f\u5728\u544a\u77e5\u8bbe\u5907\u5728\u6253\u5370\u9875\u9762\u65f6\u4f7f\u7528\u886c\u7ebf\u5b57\u4f53<\/a>\uff0c\u5728\u5c4f\u5e55\u4e0a\u663e\u793a\u65f6\u7528\u65e0\u886c\u7ebf\u5b57\u4f53\u3002\u4f46\u662f\u76ee\u524d\u6211\u53d1\u73b0\u5f88\u591a\u7f51\u7ad9\u90fd\u4f1a\u76f4\u63a5\u7701\u7565screen,\u56e0\u4e3a\u4f60\u7684\u7f51\u7ad9\u53ef\u80fd\u4e0d\u9700\u8981\u8003\u8651\u7528\u6237\u53bb\u6253\u5370\u65f6\uff0c\u4f60\u53ef\u4ee5\u76f4\u63a5\u8fd9\u6837\u5199\uff1a<\/p>\n <\/p>\n <\/p>\n \u5176\u5b9e\u5e76\u4e0d\u662f\u53ea\u6709CSS3\u624d\u652f\u6301Media\u7684\u7528\u6cd5\uff0c\u65e9\u5728CSS2\u5f00\u59cb\u5c31\u5df2\u7ecf\u652f\u6301Media\uff0c\u5177\u4f53\u7528\u6cd5\uff0c\u5c31\u662f\u5728HTML\u9875\u9762\u7684head\u6807\u7b7e\u4e2d\u63d2\u5165\u5982\u4e0b\u7684\u4e00\u6bb5\u4ee3\u7801\uff1a<\/p>\n \u4e0a\u9762\u5176\u5b9e\u662fCSS2\u5b9e\u73b0\u7684\u886c\u7ebf\u7528\u6cd5\uff0c\u90a3CSS2\u7684media\u96be\u9053\u5c31\u53ea\u80fd\u652f\u6301\u4e0a\u9762\u8fd9\u4e00\u4e2a\u529f\u80fd\u5417\uff1f\u7b54\u6848\u5f53\u7136\u4e0d\u662f\uff0c\u4ed6\u8fd8\u6709\u5f88\u591a\u7528\u6cd5\u3002<\/p>\n \u4f8b\u5982\u6211\u4eec\u60f3\u77e5\u9053\u73b0\u5728\u7684\u79fb\u52a8\u8bbe\u5907\u662f\u4e0d\u662f\u7eb5\u5411\u653e\u7f6e\u7684\u663e\u793a\u5c4f\uff0c\u53ef\u4ee5\u8fd9\u6837\u5199\uff1a<\/p>\n \u6211\u4eec\u628a\u7b2c\u4e00\u6bb5\u7684\u4ee3\u7801\u4e5f\u7528CSS2\u6765\u5b9e\u73b0\uff0c\u8ba9\u5b83\u4e00\u6837\u53ef\u4ee5\u8ba9\u9875\u9762\u5bbd\u5ea6\u5c0f\u4e8e960\u7684\u6267\u884c\u6307\u5b9a\u7684\u6837\u5f0f\u6587\u4ef6\uff1a<\/p>\n \u65e2\u7136CSS2\u53ef\u4ee5\u5b9e\u73b0CSS\u7684\u8fd9\u4e2a\u6548\u679c\u4e3a\u4ec0\u4e48\u4e0d\u7528\u8fd9\u4e2a\u65b9\u6cd5\u5462\uff0c\u5f88\u591a\u4eba\u5e94\u8be5\u4f1a\u95ee\uff0c\u4f46\u662f\u4e0a\u9762\u8fd9\u4e2a\u65b9\u6cd5\uff0c\u6700\u5927\u7684\u5f0a\u7aef\u662f\u4ed6\u4f1a\u589e\u52a0\u9875\u9762http\u7684\u8bf7\u6c42\u6b21\u6570\uff0c\u589e\u52a0\u4e86\u9875\u9762\u8d1f\u62c5\uff0c\u6211\u4eec\u7528CSS3\u628a\u6837\u5f0f\u90fd\u5199\u5728\u4e00\u4e2a\u6587\u4ef6\u91cc\u9762\u624d\u662f\u6700\u4f73\u7684\u65b9\u6cd5\u3002<\/p>\n \u4e0a\u9762\u6211\u4eec\u5927\u6982\u8bb2\u4e86\u4e0bCSS2\u7684\u5a92\u4f53\u67e5\u8be2\u7528\u6cd5\uff0c\u73b0\u5728\u6211\u4eec\u91cd\u65b0\u56de\u5230CSS3\u7684\u5a92\u4f53\u67e5\u8be2\uff0c\u5728\u7b2c\u4e00\u6bb5\u4ee3\u7801\u4e0a\u9762\u6211\u7528\u7684\u662f\u5c0f\u4e8e960px\u7684\u5c3a\u5bf8\u7684\u5199\u6cd5\uff0c\u90a3\u73b0\u5728\u6211\u4eec\u6765\u5b9e\u73b0\u7b49\u4e8e960px\u5c3a\u5bf8\u7684\u4ee3\u7801\uff1a<\/p>\n \u7136\u540e\u5c31\u662f\u5f53\u6d4f\u89c8\u5668\u5c3a\u5bf8\u5927\u4e8e960px\u65f6\u5019\u7684\u4ee3\u7801\u4e86\uff1a<\/p>\n \u6211\u4eec\u8fd8\u53ef\u4ee5\u6df7\u5408\u4f7f\u7528\u4e0a\u9762\u7684\u7528\u6cd5\uff1a<\/p>\n \u4e0a\u9762\u7684\u8fd9\u6bb5\u4ee3\u7801\u7684\u610f\u601d\u662f\u5f53\u9875\u9762\u5bbd\u5ea6\u5927\u4e8e960px\u5c0f\u4e8e1200px\u7684\u65f6\u5019\u6267\u884c\u4e0b\u9762\u7684CSS\u3002<\/p>\n <\/p>\n \u4ee5\u4e0a\u5c31\u662f\u6211\u4eec\u6700\u5e38\u9700\u8981\u7528\u5230\u7684\u5a92\u4f53\u67e5\u8be2\u5668\u7684\u4e09\u4e2a\u7279\u6027\uff0c\u5927\u4e8e\uff0c\u7b49\u4e8e\uff0c\u5c0f\u4e8e\u7684\u5199\u6cd5\u3002\u5a92\u4f53\u67e5\u8be2\u5668\u7684\u5168\u90e8\u529f\u80fd\u80af\u5b9a\u4e0d\u6b62\u8fd9\u4e09\u4e2a\u529f\u80fd\uff0c\u4e0b\u9762\u662f\u6211\u603b\u7ed3\u7684\u5b83\u7684\u4e00\u4e9b\u53c2\u6570\u7528\u6cd5\u89e3\u91ca\uff1a<\/p>\n <\/p>\n \u6ce8\u610f\u4e0b\u987a\u5e8f\uff0c\u5982\u679c\u4f60\u628a@media (min-width: 768px)\u5199\u5728\u4e86\u4e0b\u9762\u90a3\u4e48\u5f88\u60b2\u5267\uff0c<\/p>\n @media (min-width: 1200){ \/\/>=1200\u7684\u8bbe\u5907 }<\/p>\n @media (min-width: 992px){ \/\/>=992\u7684\u8bbe\u5907 }<\/p>\n @media (min-width: 768px){ \/\/>=768\u7684\u8bbe\u5907 }<\/p>\n \u56e0\u4e3a\u5982\u679c\u662f1440,\u7531\u4e8e1440>768\u90a3\u4e48\u4f60\u76841200\u5c31\u4f1a\u5931\u6548\u3002<\/p>\n \u6240\u4ee5\u6211\u4eec\u7528min-width\u65f6\uff0c\u5c0f\u7684\u653e\u4e0a\u9762\u5927\u7684\u5728\u4e0b\u9762\uff0c\u540c\u7406\u5982\u679c\u662f\u7528max-width\u90a3\u4e48\u5c31\u662f\u5927\u7684\u5728\u4e0a\u9762\uff0c\u5c0f\u7684\u5728\u4e0b\u9762<\/p>\n @media (max-width: 1199){ \/\/<=1199\u7684\u8bbe\u5907 }<\/p>\n @media (max-width: 991px){ \/\/<=991\u7684\u8bbe\u5907 }<\/p>\n @media (max-width: 767px){ \/\/<=768\u7684\u8bbe\u5907 }<\/p>\n <\/p>\n 1280\u5206\u8fa8\u7387\u4ee5\u4e0a\uff08\u5927\u4e8e1200px\uff09<\/p>\n 1100\u5206\u8fa8\u7387\uff08\u5927\u4e8e960px\uff0c\u5c0f\u4e8e1199px\uff09<\/p>\n 880\u5206\u8fa8\u7387\uff08\u5927\u4e8e768px\uff0c\u5c0f\u4e8e959px\uff09<\/p>\n 720\u5206\u8fa8\u7387\uff08\u5927\u4e8e480px\uff0c\u5c0f\u4e8e767px\uff09<\/p>\n 440\u5206\u8fa8\u7387\u4ee5\u4e0b\uff08\u5c0f\u4e8e479px\uff09<\/p>\n <\/p>\n\u51c6\u5907\u5de5\u4f5c1\uff1a\u8bbe\u7f6eMeta\u6807\u7b7e<\/h2>\n
<meta\u00a0name=\"viewport\"\u00a0content=\"width=device-width,\u00a0initial-scale=1.0,\u00a0maximum-scale=1.0,\u00a0user-scalable=no\"><\/code><\/pre>\n
\n
\u51c6\u5907\u5de5\u4f5c2\uff1a\u52a0\u8f7d\u517c\u5bb9\u6587\u4ef6JS<\/h2>\n
<!--[if lt IE 9]>\r\n <script src=\"https:\/\/oss.maxcdn.com\/libs\/html5shiv\/3.7.0\/html5shiv.js\"><\/script>\r\n <script src=\"https:\/\/oss.maxcdn.com\/libs\/respond.js\/1.3.0\/respond.min.js\"><\/script>\r\n<![endif]--><\/code><\/pre>\n
\u51c6\u5907\u5de5\u4f5c3\uff1a\u8bbe\u7f6eIE\u6e32\u67d3\u65b9\u5f0f\u9ed8\u8ba4\u4e3a\u6700\u9ad8(\u8fd9\u90e8\u5206\u53ef\u4ee5\u9009\u62e9\u6dfb\u52a0\u4e5f\u53ef\u4ee5\u4e0d\u6dfb\u52a0)<\/h2>\n
<meta\u00a0http-equiv=\"X-UA-Compatible\"\u00a0content=\"IE=edge\"><\/code><\/pre>\n
<meta http-equiv=\"X-UA-Compatible\" content=\"IE=EmulateIE9\">\uff09<\/code><\/pre>\n
<meta\u00a0http-equiv=\"X-UA-Compatible\"\u00a0content=\"IE=Edge\uff0cchrome=1\"><\/code><\/pre>\n
\u8fdb\u5165CSS3 Media\u5199\u6cd5<\/h2>\n
@media\u00a0screen\u00a0and\u00a0(max-width:\u00a0960px){\r\n\u00a0\u00a0\u00a0\u00a0body{\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0background:\u00a0#000;\r\n\u00a0\u00a0\u00a0\u00a0}\r\n}<\/code><\/pre>\n
@media\u00a0(max-width:\u00a0960px){\r\n\u00a0\u00a0\u00a0\u00a0body{\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0background:\u00a0#000;\r\n\u00a0\u00a0\u00a0\u00a0}\r\n}<\/code><\/pre>\n
CSS2 Media\u7528\u6cd5<\/h2>\n
<link\u00a0rel=\"stylesheet\"\u00a0type=\"text\/css\"\u00a0media=\"screen\"\u00a0href=\"style.css\"><\/code><\/pre>\n
<link\u00a0rel=\"stylesheet\"\u00a0type=\"text\/css\"\u00a0media=\"screen\u00a0and\u00a0(orientation:portrait)\"\u00a0href=\"style.css\"><\/code><\/pre>\n
<link\u00a0rel=\"stylesheet\"\u00a0type=\"text\/css\"\u00a0media=\"screen\u00a0and\u00a0(max-width:960px)\"\u00a0href=\"style.css\"><\/code><\/pre>\n
\u56de\u5f52CSS3 Media<\/h2>\n
@media\u00a0screen\u00a0and\u00a0(max-device-width:960px){\r\n\u00a0\u00a0\u00a0\u00a0body{\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0background:red;\r\n\u00a0\u00a0\u00a0\u00a0}\r\n}<\/code><\/pre>\n
@media\u00a0screen\u00a0and\u00a0(min-width:960px){\r\n\u00a0\u00a0\u00a0\u00a0body{\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0background:orange;\r\n\u00a0\u00a0\u00a0\u00a0}\r\n}<\/code><\/pre>\n
@media\u00a0screen\u00a0and\u00a0(min-width:960px)\u00a0and\u00a0(max-width:1200px){\r\n\u00a0\u00a0\u00a0\u00a0body{\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0background:yellow;\r\n\u00a0\u00a0\u00a0\u00a0}\r\n}<\/code><\/pre>\n
Media\u6240\u6709\u53c2\u6570\u6c47\u603b<\/h2>\n
\n
\n@media screen and (min-width:1200px){\r\n #page{ width: 1100px; }#content,.div1{width: 730px;}#secondary{width:310px}\r\n}<\/pre>\n<\/div>\n
@media screen and (min-width: 960px) and (max-width: 1199px) {\r\n #page{ width: 960px; }#content,.div1{width: 650px;}#secondary{width:250px}select{max-width:200px}\r\n}<\/pre>\n<\/div>\n
@media screen and (min-width: 768px) and (max-width: 959px) {\r\n #page{ width: 900px; }#content,.div1{width: 620px;}#secondary{width:220px}select{max-width:180px}\r\n}<\/pre>\n<\/div>\n
@media only screen and (min-width: 480px) and (max-width: 767px){\r\n #page{ width: 450px; }#content,.div1{width: 420px;position: relative; }#secondary{display:none}#access{width: 450px; }#access a {padding-right:5px}#access a img{display:none}#rss{display:none}#branding #s{display:none}\r\n}<\/pre>\n<\/div>\n
@media only screen and (max-width: 479px) {\r\n #page{ width: 300px; }#content,.div1{width: 300px;}#secondary{display:none}#access{width: 330px;} #access a {padding-right:10px;padding-left:10px}#access a img{display:none}#rss{display:none}#branding #s{display:none}#access ul ul a{width:100px}\r\n}<\/pre>\n<\/div>\n
\/* \u7ad6\u5c4f *\/\r\n@media screen and (orientation: portrait) and (max-width: 720px) { \u5bf9\u5e94\u6837\u5f0f }\r\n \r\n\/* \u6a2a\u5c4f *\/\r\n@media screen and (orientation: landscape) { \u5bf9\u5e94\u6837\u5f0f }<\/code><\/pre>\n