{"id":4900,"date":"2015-08-06T01:24:49","date_gmt":"2015-08-05T17:24:49","guid":{"rendered":"http:\/\/www.zhangxinxu.com\/wordpress\/?p=4900"},"modified":"2018-01-09T00:13:33","modified_gmt":"2018-01-08T16:13:33","slug":"know-css-at-rules","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2015\/08\/know-css-at-rules\/","title":{"rendered":"\u535a\u95fb\u5f3a\u8bc6\uff1a\u4e86\u89e3CSS\u4e2d\u7684@ AT\u89c4\u5219"},"content":{"rendered":"<p>by <a href=\"http:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"http:\/\/www.zhangxinxu.com\/\">http:\/\/www.zhangxinxu.com<\/a><br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=4900\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=4900<\/a><\/p>\n<p>\u5927\u5bb6\u53ef\u80fd\u5728CSS\u4e2d\u89c1\u5230\u8fc7\u5b57\u7b26<code>@<\/code>\u7136\u540e\u52a0\u4e00\u4e9b\u5173\u952e\u5b57\u7684\u7528\u6cd5\uff0c\u8fd9\u79cd\u7528\u6cd5\u5c31\u79f0\u4e4b\u4e3aAT\u89c4\u5219\uff0c\u5728CSS\u4e2d\uff0c\u79cd\u7c7b\u8fd8\u662f\u5f88\u591a\u7684\uff0c\u8fd9\u91cc\u603b\u7ed3\u5217\u4e3e\u4e0b\u3002<\/p>\n<h3>\u5e38\u89c4\u89c4\u5219<\/h3>\n<p>\u6240\u8c13\u201c\u5e38\u89c4\u89c4\u5219\u201d\u6307\u7684\u662f\u8bed\u6cd5\u7c7b\u4f3c\u4e0b\u9762\u7684\u89c4\u5219\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>@[KEYWORD] (RULE);<\/pre>\n<\/div>\n<p>\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>@charset<\/strong><br \/>\n\u5b9a\u4e49\u5b57\u7b26\u96c6\u3002\u5b57\u7b26\u8bbe\u7f6e\u636e\u8bf4\u4f1a\u88abHTTP\u5934\u8986\u76d6\u3002<\/p>\n<p>\u67d0\u4e9b\u8f6f\u4ef6\uff0c\u4f8b\u5982Dreamweaver\u65b0\u5efaCSS\u6587\u4ef6\u65f6\u5019\uff0c\u81ea\u52a8\u4f1a\u5e26\u6709\u4e0b\u9762\u6240\u793a\u4ee3\u7801\uff0c\u4f46\u5b9e\u9645\u5f00\u53d1\u65f6\u5019\uff0c\u4f5c\u7528\u4e0d\u5927\uff0c\u56e0\u4e3ameta\u4e2d\u5df2\u7ecf\u6709\u6240\u8bbe\u7f6e(<code>&lt;meta charset=\"utf-8\"><\/code>)\uff0c\u4f1a\u8986\u76d6\uff0c\u6240\u4ee5\u6211\u90fd\u662f\u76f4\u63a5\u5220\u6389\u7684\u3002<\/p>\n<div class=\"zxx_code\">\n<pre>@charset \"utf-8\";<\/pre>\n<\/div>\n<\/li>\n<li><strong>@import<\/strong><br \/>\n\u5bfc\u5165\u5176\u4ed6CSS\u6837\u5f0f\u6587\u4ef6\u3002\u5b9e\u9645\u4e0a\u7ebf\u65f6\u5019\uff0c\u4e0d\u5efa\u8bae\u4f7f\u7528\uff0c\u591a\u8bf7\u6c42\uff0c\u963b\u585e\u52a0\u8f7d\u4e4b\u7c7b\u3002\u4f46\uff0c\u672c\u5730\u5f00\u53d1\u53ef\u4ee5\u4f7f\u7528\uff0c\u7528\u505aCSS\u6a21\u5757\u5316\u5f00\u53d1\uff0c\u7136\u540e\u4f7f\u7528\u4e00\u4e9b(\u5982grunt)\u5de5\u5177\u8fdb\u884c\u538b\u7f29\u5e76\u5408\u5e76\u3002\u4f46\u662f\u5462\uff0c\u76f8\u6bd4less, sass\u7b49\u8fd8\u662f\u6709\u4e0d\u8db3\uff0c\u5c31\u662f<code>@import<\/code>\u8bed\u53e5\u53ea\u80fd\u5728CSS\u6587\u4ef6\u9876\u90e8\uff0c\u4f7f\u5f97\u6587\u4ef6\u7684\u524d\u540e\u5173\u7cfb\u63a7\u5236\uff0c\u5c31\u4e0d\u90a3\u4e48\u7075\u6d3b\u3002<\/p>\n<div class=\"zxx_code\">\n<pre>@import 'global.css';<\/pre>\n<\/div>\n<\/li>\n<li><strong>@namespace<\/strong><br \/>\n\u6b64\u89c4\u5219\u5e94\u7528\u5230XML HTML(XHTML)\u4e0a\u7279\u522b\u6709\u7528\uff0c\u56e0\u4e3a\u8fd9\u6837\u7684\u8bddXHTML\u5143\u7d20\u53ef\u4ee5\u4f5c\u4e3a\u9009\u62e9\u5668\u5728CSS\u4e2d\u4f7f\u7528\u3002<\/p>\n<div class=\"zxx_code\">\n<pre><span style=\"color:green;\">\/* XHTML\u547d\u540d\u7a7a\u95f4 *\/<\/span>\n@namespace url(http:\/\/www.w3.org\/1999\/xhtml);\n\n<span style=\"color:green;\">\/* \u5185\u5d4c\u5728XHTML\u7684SVG\u7684\u547d\u540d\u7a7a\u95f4 *\/<\/span>\n@namespace svg url(http:\/\/www.w3.org\/2000\/svg);<\/pre>\n<\/div>\n<\/li>\n<\/ul>\n<h3>\u5d4c\u5957\u89c4\u5219<\/h3>\n<p>\u6240\u8c13\u201c\u5d4c\u5957\u89c4\u5219\u201d\uff0c\u5c31\u662f\u5e26\u6709\u82b1\u62ec\u53f7<code>{}<\/code>, \u8bed\u6cd5\u7c7b\u4f3c\u4e0b\u9762\u7684\u89c4\u5219\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>@[KEYWORD] {\n  <span style=\"color:green;\">\/* \u5d4c\u5957\u8bed\u53e5 *\/<\/span>\n}<\/pre>\n<\/div>\n<p>\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>@document<\/strong><br \/>\nCSS 4.0\u89c4\u8303\u6709\u76f8\u5173\u8bf4\u660e\u3002\u5982\u679c\u6587\u6863\u6ee1\u8db3\u7ed9\u5b9a\u7684\u4e00\u4e9b\u6761\u4ef6\uff0c\u5c31\u53ef\u4ee5\u5e94\u7528\u6211\u4eec\u6307\u5b9a\u7684\u4e00\u4e9b\u6837\u5f0f\u3002\u6bd4\u5982\u8bf4\uff0c\u8fd9\u4e2aCSS\u6587\u4ef6\u88ab\u5b50\u7ad9A\u8c03\u7528\uff0c\u548c\u88ab\u5b50\u7ad9C\u8c03\u7528\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u57df\u540d\u5339\u914d\u6765\u6267\u884c\u4e0d\u540c\u7684CSS\u6837\u5f0f\u3002\u8fd9\u6837\uff0c\u6211\u4eec\u53ef\u4ee5\u6709\u6548\u907f\u514d\u51b2\u7a81\uff0c\u6216\u8005\u9632\u6b62\u5916\u94fe\u4e4b\u7c7b\u3002<\/p>\n<div class=\"zxx_code\">\n<pre>@document \n  <span style=\"color:green;\">\/* \u9875\u9762URL\u9700\u8981\u662f *\/<\/span>\n  url(http:\/\/www.zhangxinxu.com\/),\n  \n  <span style=\"color:green;\">\/* \u9875\u9762URL\u7684\u5f00\u5934\u5fc5\u987b\u662f... *\/<\/span>\n  url-prefix(www.zhangxinxu.com\/wordpress\/),\n  \n  <span style=\"color:green;\">\/* \u8be5\u57df\u4e0a\u7684\u6240\u6709\u9875\u9762 *\/<\/span>\n  domain(zhangxinxu.com),\n\n  <span style=\"color:green;\">\/* \u6240\u6709https\u534f\u8bae\u9875\u9762 *\/<\/span>\n  regexp(\"https:.*\")\n{\n  \n  <span style=\"color:green;\">\/* \u5f00\u59cb\u6837\u5f0f *\/<\/span>\n  body { font-family: Comic Sans; }\n\n}<\/pre>\n<\/div>\n<p>\u7531\u4e8e\u8fd9\u4e2aAT\u89c4\u5219\u662fCSS4\u6c34\u5e73\u7684\uff0c\u6240\u4ee5\u76ee\u524d\u7684\u6d4f\u89c8\u5668\u652f\u6301\u60c5\u51b5\u5f88\u5f31\uff0c\u53ea\u6709FireFox\u6d4f\u89c8\u5668\u652f\u6301\uff0c\u800c\u4e14\u8fd8\u9700\u8981\u52a0\u524d\u7f00\u3002\u4f46\u662f\uff0c10\u5e74\u4e4b\u540e\uff0c\u4e5f\u5c31\u662f2025\u5e74\u518d\u6765\u770b\uff0c\u4f30\u8ba1\u5c31\u662f\u53e6\u5916\u4e00\u756a\u666f\u8c61\u4e86\u3002<\/li>\n<li><strong>@font-face<\/strong><br \/>\n\u8fd9\u4e2a\u5927\u5bb6\u53ef\u80fd\u6bd4\u8f83\u719f\uff0c\u81ea\u5b9a\u4e49\u5b57\u4f53\u7528\u7684\u3002IE6\u4e5f\u652f\u6301\u3002\u76ee\u524d\u76f8\u5173\u6587\u7ae0\u4e5f\u633a\u591a\uff0c\u5c31\u4e0d\u5570\u55e6\uff0c\u653e\u4e2a\u793a\u610f\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>@font-face {\n  font-family: 'MyWebFont';\n  src:  url('myfont.woff2') format('woff2'),\n        url('myfont.woff') format('woff');\n}<\/pre>\n<\/div>\n<\/li>\n<li><strong>@keyframes<\/strong><br \/>\n\u559c\u6b22CSS3\u7684\u540c\u5b66\u8fd9\u4e2a\u4e5f\u8033\u719f\u80fd\u8be6\u4e86\uff0c\u8f93\u5165\u6cd5\u6253\u51fa\u6765\u53d1\u73b0\u5c45\u7136\u662f\u201c\u8be6\u201d\u800c\u4e0d\u662f\u201c\u7fd4\u201d\uff0c\u539f\u6765\u4e0d\u662f\u201c\u542c\u5f97\u592a\u591a\u8033\u6735\u90fd\u80fd\u62c9\u51fa\u5c4e\u6765\u201d\u7684\u610f\u601d\u54e6\uff0c\u5b66\u4e60\u4e86\uff01<\/p>\n<p>\u7528\u6765\u58f0\u660eCSS3 animation\u52a8\u753b\u5173\u952e\u5e27\u7528\u7684\uff0c\u4e00\u7b11\u800c\u8fc7\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>@keyframes fadeIn {\n  0% {\n    opacity: 0;\n  }\n  100% {\n    opacity: 1;\n  }\n}<\/pre>\n<\/div>\n<\/li>\n<li><strong>@media<\/strong><br \/>\n\u5a92\u4ecb\u67e5\u8be2\uff0c\u89e3\u91ca\u975e\u5e38\u5e38\u7528\u7684\u3002\u54cd\u5e94\u5f0f\u5bbd\u5ea6\u554a\uff0cretina\u5c4f\u5e55\u5224\u65ad\u5566\uff0c\u6253\u5370\u5c4f\u5e55\u5566\uff0c\u751a\u81f3IE7,IE8\u6d4f\u89c8\u5668\u7684hack\u5566\uff0c\u5f88\u591a\uff0c\u672c\u6587\u6807\u9898\u662f\u4e86\u89e3\uff0c\u4e0d\u6df1\u5165\uff0c\u7ed9\u5927\u5bb6\u7b80\u5355\u6f14\u793a\u4e0b\u4f7f\u7528\u5c31\u597d\u4e86\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>@media all and (min-width: 1280px) {\n    <span style=\"color:green;\">\/* \u5bbd\u5ea6\u5927\u4e8e1280\u5e72\u561b\u5e72\u561b\u561e... *\/<\/span> \n}<\/pre>\n<\/div>\n<div class=\"zxx_code\">\n<pre>@media \n(-webkit-min-device-pixel-ratio: 1.5), \n(min-resolution: 2dppx) { \n    <span style=\"color:green;\">\/* Retina\u5c4f\u5e55\u5e72\u561b\u5e72\u561b\u561e... *\/<\/span> \n}<\/pre>\n<\/div>\n<div class=\"zxx_code\">\n<pre>@media print {\n    <span style=\"color:green;\">\/* \u95ea\u5f00\u95ea\u5f00\uff0c\u6211\u8981\u6253\u5370\u5566\uff01 *\/<\/span> \n}<\/pre>\n<\/div>\n<div class=\"zxx_code\">\n<pre>@media \\0screen\\,screen\\9 {\n    <span style=\"color:green;\">\/* IE7,IE8\u5e72\u561b\u5e72\u561b\u561e... *\/<\/span> \n}<\/pre>\n<\/div>\n<div class=\"zxx_code\">\n<pre>@media screen\\9 {\n    <span style=\"color:green;\">\/* IE7\u5e72\u561b\u5e72\u561b\u561e... *\/<\/span> \n}<\/pre>\n<\/div>\n<\/li>\n<li><strong>@page<\/strong><br \/>\n\u8fd9\u4e2a\u89c4\u5219\u7528\u5728\u6253\u5370\u6587\u6863\u65f6\u5019\u4fee\u6539\u4e00\u4e9bCSS\u5c5e\u6027\u3002\u4f7f\u7528<code>@page<\/code>\u6211\u4eec\u53ea\u80fd\u6539\u53d8\u90e8\u5206CSS\u5c5e\u6027\uff0c\u4f8b\u5982\u95f4\u8ddd\u5c5e\u6027<code>margin<\/code>, \u6253\u5370\u76f8\u5173\u7684<code>orphans<\/code>, <code>widows<\/code>, \u4ee5\u53ca<code>page-break-*<\/code>, \u5176\u4ed6CSS\u5c5e\u6027\u4f1a\u88ab\u5ffd\u7565\u3002<\/p>\n<div class=\"zxx_code\">\n<pre>@page :first {\n  margin: 1in;\n}<\/pre>\n<\/div>\n<p>\u4e0a\u9762CSS\u8868\u793a<code>:first<\/code>\u9875\u9762\u4e5f\u8981\u6709<code>:left<\/code>, <code>:right<\/code>\u9875\u9762<code>margin<\/code>\u95f4\u8ddd\u3002<span class=\"s\">zxx: \/\/<code>@page<\/code>\u7684\u4f2a\u7c7b\u5305\u62ec\uff1a<code>:blank<\/code>, <code>:first<\/code>, <code>:left<\/code>, <code>:right<\/code><\/span>\u3002<\/li>\n<li><strong>@supports<\/strong><br \/>\n\u662f\u5426\u652f\u6301\u67d0CSS\u5c5e\u6027\u58f0\u660e\u7684AT\u89c4\u5219\uff0c\u6d4f\u89c8\u5668\u5bf9\u9f50\u652f\u6301\u6027\u8d8a\u6765\u8d8a\u597d\u4e86\uff0c\u9119\u4eba\u5df2\u7ecf\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u4f7f\u7528\u4e86\u8fd9\u4e2a\u89c4\u5219\uff0c\u5e72\u561b\u7528\u5462\uff1f\u8bf4\u6765\u60ed\u6127\uff0c\u5f53\u4f5chack\u4f7f\u7528\u4e86\u3002\u5177\u4f53\u7ec6\u8282\u4e0d\u8868\u3002\u4e0b\u9762\u662f\u4e00\u4e9b\u4f7f\u7528\u793a\u610f\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre><span style=\"color:green;\">\/* \u68c0\u67e5\u662f\u5426\u652f\u6301CSS\u58f0\u660e *\/<\/span> \n@supports (display: flex) {\n  .module { display: flex; }\n}\n\n<span style=\"color:green;\">\/* \u68c0\u67e5\u591a\u4e2a\u6761\u4ef6 *\/<\/span> \n@supports (display: flex) and (-webkit-appearance: checkbox) {\n  .module { display: flex; }\n}<\/pre>\n<\/div>\n<\/li>\n<p>\u8be5\u89c4\u5219\u7684<a href=\"http:\/\/caniuse.com\/css-supports-api\/embed\" rel=\"nofollow\" target=\"_blank\">\u6d4f\u89c8\u5668\u517c\u5bb9\u6027<\/a>\u5982\u4e0b\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201801\/2018-01-09_001124.png\" width=\"542\" height=\"267\" alt=\"css-supports\u517c\u5bb9\u6027\" class=\"alignnone\" \/><\/p>\n<\/ul>\n<h3>\u53c2\u8003\u6587\u7ae0<\/h3>\n<ul>\n<li><a href=\"https:\/\/css-tricks.com\/the-at-rules-of-css\/\">The At-Rules of CSS<\/a><\/li>\n<li><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/At-rule\">MDN-At-rule<\/a><\/li>\n<\/ul>\n<div style=\"overflow:hidden;\">\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/emtion\/smile.png\" width=\"150\" height=\"150\" alt=\"\u5fae\u7b11\" class=\"alignleft\" \/> \u672c\u6587\u5185\u5bb9\u5927\u81f4\u7ed3\u6784\u3001\u4e3b\u8981\u4fe1\u606f\u53c2\u8003\u4e0a\u9762\u4e24\u6587\u6863\u3002\u5177\u4f53\u6bcf\u4e2a\u89c4\u5219\u878d\u5165\u4e86\u81ea\u5df1\u7684\u4e00\u4e9b\u8ba4\u8bc6\u3001\u5f00\u53d1\u7ecf\u9a8c\u7b49\u3002\u6709\u4e9b\u5185\u5bb9\u5c5e\u4e8e\u7ffb\u8bd1\u6027\u8d28\uff0c\u975e\u4e25\u683c\u7ffb\u8bd1\uff0c\u53ef\u80fd\u4e0e\u539f\u610f\u6709\u8bef\u5dee\uff0c\u6b22\u8fce\u6307\u6b63\uff01<\/p>\n<p><p>\u611f\u8c22\u9605\u8bfb\uff01<\/p>\n<\/div>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u4f1a\u7ecf\u5e38\u66f4\u65b0\u77e5\u8bc6\u70b9\u4ee5\u53ca\u4fee\u6b63\u4e00\u4e9b\u9519\u8bef\uff0c\u56e0\u6b64\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u539f\u51fa\u5904\uff0c\u65b9\u4fbf\u6eaf\u6e90\uff0c\u907f\u514d\u9648\u65e7\u9519\u8bef\u77e5\u8bc6\u7684\u8bef\u5bfc\uff0c\u540c\u65f6\u6709\u66f4\u597d\u7684\u9605\u8bfb\u4f53\u9a8c\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=4900\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=4900<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5927\u5bb6\u53ef\u80fd\u5728CSS\u4e2d\u89c1\u5230\u8fc7\u5b57\u7b26@\u7136\u540e\u52a0\u4e00\u4e9b\u5173\u952e\u5b57\u7684\u7528\u6cd5\uff0c\u8fd9\u79cd\u7528\u6cd5\u5c31\u79f0\u4e4b\u4e3aAT\u89c4\u5219\u3002\u800c\u672c\u6587\u7684\u5185\u5bb9\u5c31\u662f\u5217\u4e3e\u76ee\u524dCSS\u4e2d\u652f\u6301\u7684\u6216\u5373\u5c06\u652f\u6301\u7684\u4e00\u4e9bCSS\u89c4\u5219\uff0c\u8ba9\u5927\u5bb6\u63d0\u524d\u6709\u4e2a\u5927\u81f4\u7684\u4e86\u89e3\u548c\u8ba4\u8bc6\uff0c\u5e0c\u671b\u5bf9\u65e5\u540e\u7684\u5de5\u4f5c\u4e0e\u5b66\u4e60\u80fd\u591f\u63d0\u4f9b\u4e00\u4e9b\u5e2e\u52a9\uff01<\/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":[1014,1013,1015,1012,177,655,498,682],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/4900"}],"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=4900"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/4900\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=4900"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=4900"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=4900"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}