{"id":2624,"date":"2020-04-13T20:46:34","date_gmt":"2020-04-13T12:46:34","guid":{"rendered":"http:\/\/www.yuguoxy.com\/geekhome\/?p=2624"},"modified":"2020-04-13T20:46:34","modified_gmt":"2020-04-13T12:46:34","slug":"css%e7%bc%96%e7%a0%81%e8%a7%84%e8%8c%83","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=2624","title":{"rendered":"CSS\u7f16\u7801\u89c4\u8303"},"content":{"rendered":"<p>\u672c\u6587\u6863\u867d\u9488\u5bf9CSS\u8bbe\u8ba1\u7684\uff0c\u4f46\u662f\u5728\u4f7f\u7528\u5404\u79cdCSS\u7684\u9884\u7f16\u8bd1\u5668(\u5982less\u3001sass\u3001stylus\u7b49)\u65f6\uff0c\u9002\u7528\u7684\u90e8\u5206\u4e5f\u5e94\u5c3d\u91cf\u9075\u5faa\u672c\u6587\u6863\u7684\u7ea6\u5b9a\u3002<\/p>\n<h2><strong>1 \u4ee3\u7801\u98ce\u683c<\/strong><\/h2>\n<p><strong>1.1 \u6587\u4ef6<\/strong><\/p>\n<p>[\u5efa\u8bae] CSS \u6587\u4ef6\u4f7f\u7528\u65e0 BOM \u7684 UTF-8 \u7f16\u7801\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>UTF-8 \u7f16\u7801\u5177\u6709\u66f4\u5e7f\u6cdb\u7684\u9002\u5e94\u6027\u3002BOM \u5728\u4f7f\u7528\u7a0b\u5e8f\u6216\u5de5\u5177\u5904\u7406\u6587\u4ef6\u65f6\u53ef\u80fd\u9020\u6210\u4e0d\u5fc5\u8981\u7684\u5e72\u6270\u3002<\/p>\n<p><strong>1.2 \u7f29\u8fdb<\/strong><\/p>\n<p>[\u5f3a\u5236] \u4f7f\u7528 2 \u4e2a\u7a7a\u683c\u505a\u4e3a\u4e00\u4e2a\u7f29\u8fdb\u5c42\u7ea7\uff0c\u4e0d\u5141\u8bb8\u4f7f\u7528tab \u5b57\u7b26\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">.selector {\r\n  margin: 0;\r\n  padding: 0;\r\n}<\/pre>\n<p><strong>1.3 \u7a7a\u683c<\/strong><\/p>\n<p>[\u5f3a\u5236] \u9009\u62e9\u5668 \u4e0e { \u4e4b\u95f4\u5fc5\u987b\u5305\u542b\u7a7a\u683c\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">.selector {\r\n}<\/pre>\n<p>[\u5f3a\u5236] \u5c5e\u6027\u540d \u4e0e\u4e4b\u540e\u7684 : \u4e4b\u95f4\u4e0d\u5141\u8bb8\u5305\u542b\u7a7a\u683c\uff0c : \u4e0e \u5c5e\u6027\u503c \u4e4b\u95f4\u5fc5\u987b\u5305\u542b\u7a7a\u683c\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">margin: 0;<\/pre>\n<p>[\u5f3a\u5236] \u5217\u8868\u578b\u5c5e\u6027\u503c \u4e66\u5199\u5728\u5355\u884c\u65f6\uff0c, \u540e\u5fc5\u987b\u8ddf\u4e00\u4e2a\u7a7a\u683c\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">font-family: Arial, sans-serif;<\/pre>\n<p><strong>1.4 \u884c\u957f\u5ea6<\/strong><\/p>\n<p>[\u5f3a\u5236] \u6bcf\u884c\u4e0d\u5f97\u8d85\u8fc7 120 \u4e2a\u5b57\u7b26\uff0c\u9664\u975e\u5355\u884c\u4e0d\u53ef\u5206\u5272\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>\u5e38\u89c1\u4e0d\u53ef\u5206\u5272\u7684\u573a\u666f\u4e3aURL\u8d85\u957f\u3002<\/p>\n<p>[\u5efa\u8bae] \u5bf9\u4e8e\u8d85\u957f\u7684\u6837\u5f0f\uff0c\u5728\u6837\u5f0f\u503c\u7684 \u7a7a\u683c \u5904\u6216 , \u540e\u6362\u884c\uff0c\u5efa\u8bae\u6309\u903b\u8f91\u5206\u7ec4\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* \u4e0d\u540c\u5c5e\u6027\u503c\u6309\u903b\u8f91\u5206\u7ec4 *\/\r\nbackground:\r\n  transparent url(aVeryVeryVeryLongUrlIsPlacedHere)\r\n  no-repeat 0 0;\r\n\/* \u53ef\u91cd\u590d\u591a\u6b21\u7684\u5c5e\u6027\uff0c\u6bcf\u6b21\u91cd\u590d\u4e00\u884c *\/\r\nbackground-image:\r\n  url(aVeryVeryVeryLongUrlIsPlacedHere)\r\n  url(anotherVeryVeryVeryLongUrlIsPlacedHere);\r\n\/* \u7c7b\u4f3c\u51fd\u6570\u7684\u5c5e\u6027\u503c\u53ef\u4ee5\u6839\u636e\u51fd\u6570\u8c03\u7528\u7684\u7f29\u8fdb\u8fdb\u884c *\/\r\nbackground-image: -webkit-gradient(\r\n  linear,\r\n  left bottom,\r\n  left top,\r\n  color-stop(0.04, rgb(88,94,124)),\r\n  color-stop(0.52, rgb(115,123,162))\r\n);<\/pre>\n<p><strong>1.5 \u9009\u62e9\u5668<\/strong><\/p>\n<p>[\u5f3a\u5236] \u5f53\u4e00\u4e2a rule \u5305\u542b\u591a\u4e2a selector \u65f6\uff0c\u6bcf\u4e2a\u9009\u62e9\u5668\u58f0\u660e\u5fc5\u987b\u72ec\u5360\u4e00\u884c\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\n.post,\r\n.page,\r\n.comment {\r\n  line-height: 1.5;\r\n}\r\n\/* bad *\/\r\n.post, .page, .comment {\r\n  line-height: 1.5;\r\n}<\/pre>\n<p>[\u5f3a\u5236] &gt;\u3001+\u3001~ \u9009\u62e9\u5668\u7684\u4e24\u8fb9\u5404\u4fdd\u7559\u4e00\u4e2a\u7a7a\u683c\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\nmain &gt; nav {\r\n  padding: 10px;\r\n}\r\nlabel + input {\r\n  margin-left: 5px;\r\n}\r\ninput:checked ~ button {\r\n  background-color: #69C;\r\n}\r\n\/* bad *\/\r\nmain&gt;nav {\r\n  padding: 10px;\r\n}\r\nlabel+input {\r\n  margin-left: 5px;\r\n}\r\ninput:checked~button {\r\n  background-color: #69C;\r\n}<\/pre>\n<p>[\u5f3a\u5236] \u5c5e\u6027\u9009\u62e9\u5668\u4e2d\u7684\u503c\u5fc5\u987b\u7528\u53cc\u5f15\u53f7\u5305\u56f4\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>\u4e0d\u5141\u8bb8\u4f7f\u7528\u5355\u5f15\u53f7\uff0c\u4e0d\u5141\u8bb8\u4e0d\u4f7f\u7528\u5f15\u53f7\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\narticle[character=\"juliet\"] {\r\n  voice-family: \"Vivien Leigh\", victoria, female;\r\n}\r\n\/* bad *\/\r\narticle[character='juliet'] {\r\n  voice-family: \"Vivien Leigh\", victoria, female;\r\n}<\/pre>\n<p><strong>1.6 \u5c5e\u6027<\/strong><\/p>\n<p>[\u5f3a\u5236] \u591a\u4e2a\u5c5e\u6027\u5b9a\u4e49\u5fc5\u987b\u53e6\u8d77\u4e00\u884c\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\n.selector {\r\n  margin: 0;\r\n  padding: 0;\r\n}\r\n\/* bad *\/\r\n.selector { margin: 0; padding: 0; }<\/pre>\n<p>[\u5f3a\u5236] \u5c5e\u6027\u5b9a\u4e49\u540e\u5fc5\u987b\u4ee5\u5206\u53f7\u7ed3\u5c3e\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\n.selector {\r\n  margin: 0;\r\n}\r\n\/* bad *\/\r\n.selector {\r\n  margin: 0\r\n}<\/pre>\n<h2><strong>2 \u901a\u7528<\/strong><\/h2>\n<p><strong>2.1 \u9009\u62e9\u5668<\/strong><\/p>\n<p>[\u5f3a\u5236] \u5982\u65e0\u5fc5\u8981\uff0c\u4e0d\u5f97\u4e3a id\u3001class \u9009\u62e9\u5668\u6dfb\u52a0 \u7c7b\u578b\u9009\u62e9\u5668 \u8fdb\u884c\u9650\u5b9a\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>\u5728\u6027\u80fd\u548c\u7ef4\u62a4\u6027\u4e0a\uff0c\u90fd\u6709\u4e00\u5b9a\u7684\u5f71\u54cd\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\n#error,\r\n.danger-message {\r\n  font-color: #c00;\r\n}\r\n\/* bad *\/\r\ndialog#error,\r\np.danger-message {\r\n  font-color: #c00;\r\n}<\/pre>\n<p>[\u5efa\u8bae] \u9009\u62e9\u5668\u7684\u5d4c\u5957\u5c42\u7ea7\u5e94\u4e0d\u5927\u4e8e 4 \u7ea7\uff0c\u4f4d\u7f6e\u9760\u540e\u7684\u9650\u5b9a\u6761\u4ef6\u5e94\u5c3d\u53ef\u80fd\u7cbe\u786e\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\n#username input {}\r\n.comment .avatar {}\r\n\/* bad *\/\r\n.page .header .login #username input {}\r\n.comment div * {}<\/pre>\n<p><strong>2.2 \u5c5e\u6027\u7f29\u5199<\/strong><\/p>\n<p>[\u5efa\u8bae] \u5728\u53ef\u4ee5\u4f7f\u7528\u7f29\u5199\u7684\u60c5\u51b5\u4e0b\uff0c\u5c3d\u91cf\u4f7f\u7528\u5c5e\u6027\u7f29\u5199\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\n.post {\r\n  font: 12px\/1.5 arial, sans-serif;\r\n}\r\n\/* bad *\/\r\n.post {\r\n  font-family: arial, sans-serif;\r\n  font-size: 12px;\r\n  line-height: 1.5;\r\n}<\/pre>\n<p>[\u5efa\u8bae] \u4f7f\u7528 border \/ margin \/ padding \u7b49\u7f29\u5199\u65f6\uff0c\u5e94\u6ce8\u610f\u9690\u542b\u503c\u5bf9\u5b9e\u9645\u6570\u503c\u7684\u5f71\u54cd\uff0c\u786e\u5b9e\u9700\u8981\u8bbe\u7f6e\u591a\u4e2a\u65b9\u5411\u7684\u503c\u65f6\u624d\u4f7f\u7528\u7f29\u5199\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>border \/ margin \/ padding \u7b49\u7f29\u5199\u4f1a\u540c\u65f6\u8bbe\u7f6e\u591a\u4e2a\u5c5e\u6027\u7684\u503c\uff0c\u5bb9\u6613\u8986\u76d6\u4e0d\u9700\u8981\u8986\u76d6\u7684\u8bbe\u5b9a\u3002\u5982\u67d0\u4e9b\u65b9\u5411\u9700\u8981\u7ee7\u627f\u5176\u4ed6\u58f0\u660e\u7684\u503c\uff0c\u5219\u5e94\u8be5\u5206\u5f00\u8bbe\u7f6e\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* centering &lt;article class=\"page\"&gt; horizontally and highlight featured ones *\/\r\narticle {\r\n  margin: 5px;\r\n  border: 1px solid #999;\r\n}\r\n\/* good *\/\r\n.page {\r\n  margin-right: auto;\r\n  margin-left: auto;\r\n}\r\n.featured {\r\n  border-color: #69c;\r\n}\r\n\/* bad *\/\r\n.page {\r\n  margin: 5px auto; \/* introducing redundancy *\/\r\n}\r\n.featured {\r\n  border: 1px solid #69c; \/* introducing redundancy *\/\r\n}<\/pre>\n<p><strong>2.3 \u5c5e\u6027\u4e66\u5199\u987a\u5e8f<\/strong><\/p>\n<p>[\u5efa\u8bae] \u540c\u4e00 rule set \u4e0b\u7684\u5c5e\u6027\u5728\u4e66\u5199\u65f6\uff0c\u5e94\u6309\u529f\u80fd\u8fdb\u884c\u5206\u7ec4\uff0c\u5e76\u4ee5 Formatting Model\uff08\u5e03\u5c40\u65b9\u5f0f\u3001\u4f4d\u7f6e\uff09 &gt; Box Model\uff08\u5c3a\u5bf8\uff09 &gt; Typographic\uff08\u6587\u672c\u76f8\u5173\uff09 &gt; Visual\uff08\u89c6\u89c9\u6548\u679c\uff09 \u7684\u987a\u5e8f\u4e66\u5199\uff0c\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>Formatting Model \u76f8\u5173\u5c5e\u6027\u5305\u62ec\uff1aposition \/ top \/ right \/ bottom \/ left \/ float \/ display \/ overflow \u7b49<\/p>\n<p>Box Model \u76f8\u5173\u5c5e\u6027\u5305\u62ec\uff1aborder \/ margin \/ padding \/ width \/ height \u7b49<\/p>\n<p>Typographic \u76f8\u5173\u5c5e\u6027\u5305\u62ec\uff1afont \/ line-height \/ text-align \/ word-wrap \u7b49<\/p>\n<p>Visual \u76f8\u5173\u5c5e\u6027\u5305\u62ec\uff1abackground \/ color \/ transition \/ list-style \u7b49<\/p>\n<p>Misc \u76f8\u5173\u5c5e\u6027\u5305\u62ec\uff1aopacity \/ text-decoration \/ white-space \/ word-wrap \u7b49<\/p>\n<p>\u53e6\u5916\uff0c\u5982\u679c\u5305\u542b content \u5c5e\u6027\uff0c\u5e94\u653e\u5728\u6700\u524d\u9762\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">.sidebar {\r\n  \/* formatting model: positioning schemes \/ offsets \/ z-indexes \/ display \/ ...  *\/\r\n  position: absolute;\r\n  top: 50px;\r\n  left: 0;\r\n  overflow-x: hidden;\r\n  display: block;\r\n  \/* box model: sizes \/ margins \/ paddings \/ borders \/ ...  *\/\r\n  width: 200px;\r\n  padding: 5px;\r\n  border: 1px solid #ddd;\r\n  \/* typographic: font \/ aligns \/ text styles \/ ... *\/\r\n  font-size: 14px;\r\n  line-height: 20px;\r\n  \/* visual: colors \/ shadows \/ gradients \/ ... *\/\r\n  background: #f5f5f5;\r\n  color: #333;\r\n  -webkit-transition: color 1s;\r\n     -moz-transition: color 1s;\r\n          transition: color 1s;\r\n  \/* Misc *\/\r\n  opacity: 1;\r\n  text-decoration: none;\r\n  white-space: nowrap;\r\n  word-wrap: normal;\r\n  cursor: pointer;\r\n}<\/pre>\n<p><strong>2.4 \u6e05\u9664\u6d6e\u52a8<\/strong><\/p>\n<p>[\u5efa\u8bae] \u5f53\u5143\u7d20\u9700\u8981\u6491\u8d77\u9ad8\u5ea6\u4ee5\u5305\u542b\u5185\u90e8\u7684\u6d6e\u52a8\u5143\u7d20\u65f6\uff0c\u901a\u8fc7\u5bf9\u4f2a\u7c7b\u8bbe\u7f6e clear \u6216\u89e6\u53d1 BFC \u7684\u65b9\u5f0f\u8fdb\u884c clearfix\u3002\u5c3d\u91cf\u4e0d\u4f7f\u7528\u589e\u52a0\u7a7a\u6807\u7b7e\u7684\u65b9\u5f0f\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>\u89e6\u53d1 BFC \u7684\u65b9\u5f0f\u5f88\u591a\uff0c\u5e38\u89c1\u7684\u6709\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">float \u975e none\r\nposition \u975e static\r\noverflow \u975e visible<\/pre>\n<p>\u5982\u5e0c\u671b\u4f7f\u7528\u66f4\u5c0f\u526f\u4f5c\u7528\u7684\u6e05\u9664\u6d6e\u52a8\u65b9\u6cd5\uff0c\u53c2\u89c1\u00a0<a href=\"http:\/\/nicolasgallagher.com\/micro-clearfix-hack\/\" target=\"_blank\" rel=\"nofollow\">A new micro clearfix hack<\/a>\u00a0\u4e00\u6587\u3002<\/p>\n<p>\u53e6\u9700\u6ce8\u610f\uff0c\u5bf9\u5df2\u7ecf\u89e6\u53d1 BFC \u7684\u5143\u7d20\u4e0d\u9700\u8981\u518d\u8fdb\u884c clearfix\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">&lt;div class=\"fn-clear\"&gt;\r\n    &lt;div class=\"fn-left\"&gt;&lt;\/div&gt;\r\n    &lt;div class=\"fn-left\"&gt;&lt;\/div&gt;\r\n&lt;\/div&gt;<\/pre>\n<p><strong>2.5 !important<\/strong><\/p>\n<p>[\u5efa\u8bae] \u5c3d\u91cf\u4e0d\u4f7f\u7528 !important \u58f0\u660e\u3002<\/p>\n<p>[\u5efa\u8bae] \u5f53\u9700\u8981\u5f3a\u5236\u6307\u5b9a\u6837\u5f0f\u4e14\u4e0d\u5141\u8bb8\u4efb\u4f55\u573a\u666f\u8986\u76d6\u65f6\uff0c\u901a\u8fc7\u6807\u7b7e\u5185\u8054\u548c !important \u5b9a\u4e49\u6837\u5f0f\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>\u5fc5\u987b\u6ce8\u610f\u7684\u662f\uff0c\u4ec5\u5728\u8bbe\u8ba1\u4e0a \u786e\u5b9e\u4e0d\u5141\u8bb8\u4efb\u4f55\u5176\u5b83\u573a\u666f\u8986\u76d6\u6837\u5f0f \u65f6\uff0c\u624d\u4f7f\u7528\u5185\u8054\u7684 !important \u6837\u5f0f\u3002\u901a\u5e38\u5728\u7b2c\u4e09\u65b9\u73af\u5883\u7684\u5e94\u7528\u4e2d\u4f7f\u7528\u8fd9\u79cd\u65b9\u6848\u3002\u4e0b\u9762\u7684 z-index \u7ae0\u8282\u662f\u5176\u4e2d\u4e00\u4e2a\u7279\u6b8a\u573a\u666f\u7684\u5178\u578b\u6837\u4f8b\u3002<\/p>\n<p><strong>2.6 z-index<\/strong><\/p>\n<p>[\u5efa\u8bae] \u5c06 z-index \u8fdb\u884c\u5206\u5c42\uff0c\u5bf9\u6587\u6863\u6d41\u5916\u7edd\u5bf9\u5b9a\u4f4d\u5143\u7d20\u7684\u89c6\u89c9\u5c42\u7ea7\u5173\u7cfb\u8fdb\u884c\u7ba1\u7406\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>\u540c\u5c42\u7684\u591a\u4e2a\u5143\u7d20\uff0c\u5982\u591a\u4e2a\u7531\u7528\u6237\u8f93\u5165\u89e6\u53d1\u7684 Dialog\uff0c\u5728\u8be5\u5c42\u7ea7\u5185\u4f7f\u7528\u76f8\u540c\u7684 z-index \u6216\u9012\u589e z-index\u3002<\/p>\n<p>\u5efa\u8bae\u6bcf\u5c42\u5305\u542b100\u4e2a z-index \u6765\u5bb9\u7eb3\u8db3\u591f\u7684\u5143\u7d20\uff0c\u5982\u679c\u6bcf\u5c42\u5143\u7d20\u8f83\u591a\uff0c\u53ef\u4ee5\u8c03\u6574\u8fd9\u4e2a\u6570\u503c\u3002<\/p>\n<p>[\u5efa\u8bae] \u5728\u53ef\u63a7\u73af\u5883\u4e0b\uff0c\u671f\u671b\u663e\u793a\u5728\u6700\u4e0a\u5c42\u7684\u5143\u7d20\uff0cz-index \u6307\u5b9a\u4e3a 9999\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>\u53ef\u63a7\u73af\u5883\u5206\u6210\u4e24\u79cd\uff0c\u4e00\u79cd\u662f\u81ea\u8eab\u4ea7\u54c1\u7ebf\u73af\u5883\uff1b\u8fd8\u6709\u4e00\u79cd\u662f\u53ef\u80fd\u4f1a\u88ab\u5176\u4ed6\u4ea7\u54c1\u7ebf\u5f15\u7528\uff0c\u4f46\u662f\u4e0d\u4f1a\u88ab\u5916\u90e8\u7b2c\u4e09\u65b9\u7684\u4ea7\u54c1\u5f15\u7528\u3002<\/p>\n<p>\u4e0d\u5efa\u8bae\u53d6\u503c\u4e3a 2147483647\u3002\u4ee5\u4fbf\u4e8e\u81ea\u8eab\u4ea7\u54c1\u7ebf\u88ab\u5176\u4ed6\u4ea7\u54c1\u7ebf\u5f15\u7528\u65f6\uff0c\u5f53\u9047\u5230\u5c42\u7ea7\u8986\u76d6\u51b2\u7a81\u7684\u60c5\u51b5\uff0c\u7559\u51fa\u5411\u4e0a\u8c03\u6574\u7684\u7a7a\u95f4\u3002<\/p>\n<p>[\u5efa\u8bae] \u5728\u7b2c\u4e09\u65b9\u73af\u5883\u4e0b\uff0c\u671f\u671b\u663e\u793a\u5728\u6700\u4e0a\u5c42\u7684\u5143\u7d20\uff0c\u901a\u8fc7\u6807\u7b7e\u5185\u8054\u548c !important\uff0c\u5c06 z-index \u6307\u5b9a\u4e3a 2147483647\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>\u7b2c\u4e09\u65b9\u73af\u5883\u5bf9\u4e8e\u5f00\u53d1\u8005\u6765\u8bf4\u5b8c\u5168\u4e0d\u53ef\u63a7\u3002\u5728\u7b2c\u4e09\u65b9\u73af\u5883\u4e0b\u7684\u5143\u7d20\uff0c\u4e3a\u4e86\u4fdd\u8bc1\u5143\u7d20\u4e0d\u88ab\u5176\u9875\u9762\u5176\u4ed6\u6837\u5f0f\u5b9a\u4e49\u8986\u76d6\uff0c\u9700\u8981\u91c7\u7528\u6b64\u505a\u6cd5\u3002<\/p>\n<h2><strong>3 \u503c\u4e0e\u5355\u4f4d<\/strong><\/h2>\n<p><strong>3.1 \u6587\u672c<\/strong><\/p>\n<p>[\u5f3a\u5236] \u6587\u672c\u5185\u5bb9\u5fc5\u987b\u7528\u53cc\u5f15\u53f7\u5305\u56f4\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>\u6587\u672c\u7c7b\u578b\u7684\u5185\u5bb9\u53ef\u80fd\u5728\u9009\u62e9\u5668\u3001\u5c5e\u6027\u503c\u7b49\u5185\u5bb9\u4e2d\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\nhtml[lang|=\"zh\"] q:before {\r\n  font-family: \"Microsoft YaHei\", sans-serif;\r\n  content: \"\u201c\";\r\n}\r\nhtml[lang|=\"zh\"] q:after {\r\n  font-family: \"Microsoft YaHei\", sans-serif;\r\n  content: \"\u201d\";\r\n}\r\n\/* bad *\/\r\nhtml[lang|=zh] q:before {\r\n  font-family: 'Microsoft YaHei', sans-serif;\r\n  content: '\u201c';\r\n}\r\nhtml[lang|=zh] q:after {\r\n  font-family: \"Microsoft YaHei\", sans-serif;\r\n  content: \"\u201d\";\r\n}<\/pre>\n<p><strong>3.2 \u6570\u503c<\/strong><\/p>\n<p>[\u5f3a\u5236] \u5f53\u6570\u503c\u4e3a 0 &#8211; 1 \u4e4b\u95f4\u7684\u5c0f\u6570\u65f6\uff0c\u7701\u7565\u6574\u6570\u90e8\u5206\u7684 0\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\npanel {\r\n  opacity: .8\r\n}\r\n\/* bad *\/\r\npanel {\r\n  opacity: 0.8\r\n}<\/pre>\n<p><strong>3.3 url()<\/strong><\/p>\n<p>[\u5f3a\u5236] url() \u51fd\u6570\u4e2d\u7684\u8def\u5f84\u4e0d\u52a0\u5f15\u53f7\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\nbody {\r\n  background: url(bg.png);\r\n}\r\n\/* bad *\/\r\nbody {\r\n  background: url(\"bg.png\");\r\n}<\/pre>\n<p>[\u5f3a\u5236] url() \u51fd\u6570\u4e2d\u7684\u7edd\u5bf9\u8def\u5f84\u53ef\u7701\u53bb\u534f\u8bae\u540d\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">body {\r\n  background: url(\/\/w.zuzuche.com\/img\/bg.png) no-repeat 0 0;\r\n}<\/pre>\n<p><strong>3.4 \u957f\u5ea6<\/strong><\/p>\n<p>[\u5f3a\u5236] \u957f\u5ea6\u4e3a 0 \u65f6\u987b\u7701\u7565\u5355\u4f4d\u3002 (\u4e5f\u53ea\u6709\u957f\u5ea6\u5355\u4f4d\u53ef\u7701)<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\nbody {\r\n  padding: 0 5px;\r\n}\r\n\/* bad *\/\r\nbody {\r\n  padding: 0px 5px;\r\n}<\/pre>\n<p><strong>3.5 \u989c\u8272<\/strong><\/p>\n<p>[\u5f3a\u5236] RGB\u989c\u8272\u503c\u5fc5\u987b\u4f7f\u7528\u5341\u516d\u8fdb\u5236\u8bb0\u53f7\u5f62\u5f0f #rrggbb\u3002\u4e0d\u5141\u8bb8\u4f7f\u7528 rgb()\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>\u5e26\u6709alpha\u7684\u989c\u8272\u4fe1\u606f\u53ef\u4ee5\u4f7f\u7528 rgba()\u3002\u4f7f\u7528 rgba() \u65f6\u6bcf\u4e2a\u9017\u53f7\u540e\u5fc5\u987b\u4fdd\u7559\u4e00\u4e2a\u7a7a\u683c\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\n.success {\r\n  box-shadow: 0 0 2px rgba(0, 128, 0, .3);\r\n  border-color: #008000;\r\n}\r\n\/* bad *\/\r\n.success {\r\n  box-shadow: 0 0 2px rgba(0,128,0,.3);\r\n  border-color: rgb(0, 128, 0);\r\n}<\/pre>\n<p>[\u5f3a\u5236] \u989c\u8272\u503c\u53ef\u4ee5\u7f29\u5199\u65f6\uff0c\u5fc5\u987b\u4f7f\u7528\u7f29\u5199\u5f62\u5f0f\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\n.success {\r\n  background-color: #aca;\r\n}\r\n\/* bad *\/\r\n.success {\r\n  background-color: #aaccaa;\r\n}<\/pre>\n<p>[\u5f3a\u5236] \u989c\u8272\u503c\u4e0d\u5141\u8bb8\u4f7f\u7528\u547d\u540d\u8272\u503c\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\n.success {\r\n    color: #90ee90;\r\n}\r\n\/* bad *\/\r\n.success {\r\n    color: lightgreen;\r\n}<\/pre>\n<p>[\u5efa\u8bae] \u989c\u8272\u503c\u4e2d\u7684\u82f1\u6587\u5b57\u7b26\u91c7\u7528\u5c0f\u5199\u3002\u5982\u4e0d\u7528\u5c0f\u5199\u4e5f\u9700\u8981\u4fdd\u8bc1\u540c\u4e00\u9879\u76ee\u5185\u4fdd\u6301\u5927\u5c0f\u5199\u4e00\u81f4\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\n.success {\r\n  background-color: #aca;\r\n  color: #90ee90;\r\n}\r\n\/* good *\/\r\n.success {\r\n  background-color: #ACA;\r\n  color: #90EE90;\r\n}\r\n\/* bad *\/\r\n.success {\r\n  background-color: #ACA;\r\n  color: #90ee90;\r\n}<\/pre>\n<p><strong>3.6 2D \u4f4d\u7f6e<\/strong><\/p>\n<p>[\u5f3a\u5236] \u5fc5\u987b\u540c\u65f6\u7ed9\u51fa\u6c34\u5e73\u548c\u5782\u76f4\u65b9\u5411\u7684\u4f4d\u7f6e\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>2D \u4f4d\u7f6e\u521d\u59cb\u503c\u4e3a 0% 0%\uff0c\u4f46\u5728\u53ea\u6709\u4e00\u4e2a\u65b9\u5411\u7684\u503c\u65f6\uff0c\u53e6\u4e00\u4e2a\u65b9\u5411\u7684\u503c\u4f1a\u88ab\u89e3\u6790\u4e3a center\u3002\u4e3a\u907f\u514d\u7406\u89e3\u4e0a\u7684\u56f0\u6270\uff0c\u5e94\u540c\u65f6\u7ed9\u51fa\u4e24\u4e2a\u65b9\u5411\u7684\u503c\u3002<a href=\"https:\/\/www.w3.org\/TR\/CSS21\/colors.html#propdef-background-position\" target=\"_blank\" rel=\"nofollow\">background-position\u5c5e\u6027\u503c\u7684\u5b9a\u4e49<\/a><\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\nbody {\r\n  background-position: center top; \/* 50% 0% *\/\r\n}\r\n\/* bad *\/\r\nbody {\r\n  background-position: top; \/* 50% 0% *\/\r\n}<\/pre>\n<h2><strong>4 \u6587\u672c\u7f16\u6392<\/strong><\/h2>\n<p><strong>4.1 \u5b57\u4f53\u65cf<\/strong><\/p>\n<p>[\u5f3a\u5236] font-family \u5c5e\u6027\u4e2d\u7684\u5b57\u4f53\u65cf\u540d\u79f0\u5e94\u4f7f\u7528\u5b57\u4f53\u7684\u82f1\u6587 Family Name\uff0c\u5176\u4e2d\u5982\u6709\u7a7a\u683c\uff0c\u987b\u653e\u7f6e\u5728\u5f15\u53f7\u4e2d\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>\u6240\u8c13\u82f1\u6587 Family Name\uff0c\u4e3a\u5b57\u4f53\u6587\u4ef6\u7684\u4e00\u4e2a\u5143\u6570\u636e\uff0c\u5e38\u89c1\u540d\u79f0\u5982\u4e0b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\u5b57\u4f53\u64cd\u4f5c\u7cfb\u7edfFamily Name\r\n\u5b8b\u4f53 (\u4e2d\u6613\u5b8b\u4f53)WindowsSimSun\r\n\u9ed1\u4f53 (\u4e2d\u6613\u9ed1\u4f53)WindowsSimHei\r\n\u5fae\u8f6f\u96c5\u9ed1WindowsMicrosoft YaHei\r\n\u5fae\u8f6f\u6b63\u9ed1WindowsMicrosoft JhengHei\r\n\u534e\u6587\u9ed1\u4f53Mac\/iOSSTHeiti\r\n\u51ac\u9752\u9ed1\u4f53Mac\/iOSHiragino Sans GB\r\n\u6587\u6cc9\u9a7f\u6b63\u9ed1LinuxWenQuanYi Zen Hei\r\n\u6587\u6cc9\u9a7f\u5fae\u7c73\u9ed1LinuxWenQuanYi Micro Hei<\/pre>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">h1 {\r\n  font-family: \"Microsoft YaHei\";\r\n}<\/pre>\n<p>[\u5f3a\u5236] font-family \u6309\u300c\u897f\u6587\u5b57\u4f53\u5728\u524d\u3001\u4e2d\u6587\u5b57\u4f53\u5728\u540e\u300d\u3001\u300c\u6548\u679c\u4f73 (\u8d28\u91cf\u9ad8\/\u66f4\u80fd\u6ee1\u8db3\u9700\u6c42) \u7684\u5b57\u4f53\u5728\u524d\u3001\u6548\u679c\u4e00\u822c\u7684\u5b57\u4f53\u5728\u540e\u300d\u7684\u987a\u5e8f\u7f16\u5199\uff0c\u6700\u540e\u5fc5\u987b\u6307\u5b9a\u4e00\u4e2a\u901a\u7528\u5b57\u4f53\u65cf( serif \/ sans-serif )\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>\u66f4\u8be6\u7ec6\u8bf4\u660e\u53ef\u53c2\u8003\u672c\u6587\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* Display according to platform *\/\r\n.article {\r\n  font-family: Arial, sans-serif;\r\n}\r\n\/* Specific for most platforms *\/\r\nh1 {\r\n  font-family: \"Helvetica Neue\", Arial, \"Hiragino Sans GB\", \r\n         \"WenQuanYi Micro Hei\", \"Microsoft YaHei\", sans-serif;\r\n}<\/pre>\n<p>[\u5f3a\u5236] font-family \u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff0c\u4f46\u5728\u540c\u4e00\u4e2a\u9879\u76ee\u4e2d\uff0c\u540c\u6837\u7684 Family Name \u5927\u5c0f\u5199\u5fc5\u987b\u7edf\u4e00\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\nbody {\r\n  font-family: Arial, sans-serif;\r\n}\r\nh1 {\r\n  font-family: Arial, \"Microsoft YaHei\", sans-serif;\r\n}\r\n\/* bad *\/\r\nbody {\r\n  font-family: arial, sans-serif;\r\n}\r\nh1 {\r\n  font-family: Arial, \"Microsoft YaHei\", sans-serif;\r\n}<\/pre>\n<p><strong>4.2 \u5b57\u53f7<\/strong><\/p>\n<p>[\u5f3a\u5236] \u9700\u8981\u5728 Windows \u5e73\u53f0\u663e\u793a\u7684\u4e2d\u6587\u5185\u5bb9\uff0c\u5176\u5b57\u53f7\u5e94\u4e0d\u5c0f\u4e8e 12px\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>\u7531\u4e8e Windows \u7684\u5b57\u4f53\u6e32\u67d3\u673a\u5236\uff0c\u5c0f\u4e8e 12px \u7684\u6587\u5b57\u663e\u793a\u6548\u679c\u6781\u5dee\u3001\u96be\u4ee5\u8fa8\u8ba4\u3002<\/p>\n<p><strong>4.3 \u5b57\u4f53\u98ce\u683c<\/strong><\/p>\n<p>[\u5efa\u8bae] \u9700\u8981\u5728 Windows \u5e73\u53f0\u663e\u793a\u7684\u4e2d\u6587\u5185\u5bb9\uff0c\u4e0d\u8981\u4f7f\u7528\u9664 normal \u5916\u7684 font-style\u3002\u5176\u4ed6\u5e73\u53f0\u4e5f\u5e94\u614e\u7528\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>\u7531\u4e8e\u4e2d\u6587\u5b57\u4f53\u6ca1\u6709 italic \u98ce\u683c\u7684\u5b9e\u73b0\uff0c\u6240\u6709\u6d4f\u89c8\u5668\u4e0b\u90fd\u4f1a fallback \u5230 obilique \u5b9e\u73b0 (\u81ea\u52a8\u62df\u5408\u4e3a\u659c\u4f53)\uff0c\u5c0f\u5b57\u53f7\u4e0b (\u7279\u522b\u662f Windows \u4e0b\u4f1a\u5728\u5c0f\u5b57\u53f7\u4e0b\u4f7f\u7528\u70b9\u9635\u5b57\u4f53\u7684\u60c5\u51b5\u4e0b) \u663e\u793a\u6548\u679c\u5dee\uff0c\u9020\u6210\u9605\u8bfb\u56f0\u96be\u3002<\/p>\n<p><strong>4.4 \u5b57\u91cd<\/strong><\/p>\n<p>[\u5f3a\u5236] font-weight \u5c5e\u6027\u5fc5\u987b\u4f7f\u7528\u6570\u503c\u65b9\u5f0f\u63cf\u8ff0\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>CSS \u7684\u5b57\u91cd\u5206 100 \u2013 900 \u5171\u4e5d\u6863\uff0c\u4f46\u76ee\u524d\u53d7\u5b57\u4f53\u672c\u8eab\u8d28\u91cf\u548c\u6d4f\u89c8\u5668\u7684\u9650\u5236\uff0c\u5b9e\u9645\u4e0a\u652f\u6301 400 \u548c 700 \u4e24\u6863\uff0c\u5206\u522b\u7b49\u4ef7\u4e8e\u5173\u952e\u8bcd normal \u548c bold\u3002<\/p>\n<p>\u6d4f\u89c8\u5668\u672c\u8eab\u4f7f\u7528\u4e00\u7cfb\u5217<a href=\"https:\/\/www.w3.org\/TR\/CSS21\/fonts.html#propdef-font-weight\" target=\"_blank\" rel=\"nofollow\">\u542f\u53d1\u5f0f\u89c4\u5219<\/a>\u6765\u8fdb\u884c\u5339\u914d\uff0c\u5728 &lt;700 \u65f6\u4e00\u822c\u5339\u914d\u5b57\u4f53\u7684 Regular \u5b57\u91cd\uff0c&gt;=700 \u65f6\u5339\u914d Bold \u5b57\u91cd\u3002<\/p>\n<p>\u4f46\u5df2\u6709\u6d4f\u89c8\u5668\u5f00\u59cb\u652f\u6301 =600 \u65f6\u5339\u914d Semibold \u5b57\u91cd (\u89c1<a href=\"http:\/\/justineo.github.io\/slideshows\/font\/#\/3\/15\" target=\"_blank\" rel=\"nofollow\">\u6b64\u8868<\/a>)\uff0c\u6545\u4f7f\u7528\u6570\u503c\u63cf\u8ff0\u589e\u52a0\u4e86\u7075\u6d3b\u6027\uff0c\u4e5f\u66f4\u7b80\u77ed\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\nh1 {\r\n  font-weight: 700;\r\n}\r\n\/* bad *\/\r\nh1 {\r\n  font-weight: bold;\r\n}<\/pre>\n<p><strong>4.5 \u884c\u9ad8<\/strong><\/p>\n<p>[\u5efa\u8bae] line-height \u5728\u5b9a\u4e49\u6587\u672c\u6bb5\u843d\u65f6\uff0c\u5e94\u4f7f\u7528\u6570\u503c\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>\u5c06 line-height \u8bbe\u7f6e\u4e3a\u6570\u503c\uff0c\u6d4f\u89c8\u5668\u4f1a\u57fa\u4e8e\u5f53\u524d\u5143\u7d20\u8bbe\u7f6e\u7684 font-size \u8fdb\u884c\u518d\u6b21\u8ba1\u7b97\u3002\u5728\u4e0d\u540c\u5b57\u53f7\u7684\u6587\u672c\u6bb5\u843d\u7ec4\u5408\u4e2d\uff0c\u80fd\u8fbe\u5230\u8f83\u4e3a\u8212\u9002\u7684\u884c\u95f4\u95f4\u9694\u6548\u679c\uff0c\u907f\u514d\u5728\u6bcf\u4e2a\u8bbe\u7f6e\u4e86 font-size \u90fd\u9700\u8981\u8bbe\u7f6e line-height\u3002<\/p>\n<p>\u5f53 line-height \u7528\u4e8e\u63a7\u5236\u5782\u76f4\u5c45\u4e2d\u65f6\uff0c\u8fd8\u662f\u5e94\u8be5\u8bbe\u7f6e\u6210\u4e0e\u5bb9\u5668\u9ad8\u5ea6\u4e00\u81f4\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">.container {\r\n  line-height: 1.5;\r\n}<\/pre>\n<h2><strong>5 \u53d8\u6362\u4e0e\u52a8\u753b<\/strong><\/h2>\n<p>[\u5f3a\u5236] \u4f7f\u7528 transition \u65f6\u5e94\u6307\u5b9a transition-property\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\n.box {\r\n  transition: color 1s, border-color 1s;\r\n}\r\n\/* bad *\/\r\n.box {\r\n  transition: all 1s;\r\n}<\/pre>\n<p>[\u5efa\u8bae] \u5c3d\u53ef\u80fd\u5728\u6d4f\u89c8\u5668\u80fd\u9ad8\u6548\u5b9e\u73b0\u7684\u5c5e\u6027\u4e0a\u6dfb\u52a0\u8fc7\u6e21\u548c\u52a8\u753b\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>\u89c1\u672c\u6587\uff0c\u5728\u53ef\u80fd\u7684\u60c5\u51b5\u4e0b\u5e94\u9009\u62e9\u8fd9\u6837\u56db\u79cd\u53d8\u6362\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">transform: translate(npx, npx);\r\ntransform: scale(n);\r\ntransform: rotate(ndeg);\r\nopacity: 0..1;<\/pre>\n<p>\u5178\u578b\u7684\uff0c\u53ef\u4ee5\u4f7f\u7528 translate \u6765\u4ee3\u66ff left \u4f5c\u4e3a\u52a8\u753b\u5c5e\u6027\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* good *\/\r\n.box {\r\n  transition: transform 1s;\r\n}\r\n.box:hover {\r\n  transform: translate(20px); \/* move right for 20px *\/\r\n}\r\n\/* bad *\/\r\n.box {\r\n  left: 0;\r\n  transition: left 1s;\r\n}\r\n.box:hover {\r\n  left: 20px; \/* move right for 20px *\/\r\n}<\/pre>\n<h2><strong>6 \u54cd\u5e94\u5f0f<\/strong><\/h2>\n<p>[\u5f3a\u5236] Media Query \u4e0d\u5f97\u5355\u72ec\u7f16\u6392\uff0c\u5fc5\u987b\u4e0e\u76f8\u5173\u7684\u89c4\u5219\u4e00\u8d77\u5b9a\u4e49\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* Good *\/\r\n\/* header styles *\/\r\n@media (...) {\r\n  \/* header styles *\/\r\n}\r\n\/* main styles *\/\r\n@media (...) {\r\n  \/* main styles *\/\r\n}\r\n\/* footer styles *\/\r\n@media (...) {\r\n  \/* footer styles *\/\r\n}\r\n\/* Bad *\/\r\n\/* header styles *\/\r\n\/* main styles *\/\r\n\/* footer styles *\/\r\n@media (...) {\r\n  \/* header styles *\/\r\n  \/* main styles *\/\r\n  \/* footer styles *\/\r\n}<\/pre>\n<p>[\u5f3a\u5236] Media Query \u5982\u679c\u6709\u591a\u4e2a\u9017\u53f7\u5206\u9694\u7684\u6761\u4ef6\u65f6\uff0c\u5e94\u5c06\u6bcf\u4e2a\u6761\u4ef6\u653e\u5728\u5355\u72ec\u4e00\u884c\u4e2d\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">@media\r\n(-webkit-min-device-pixel-ratio: 2), \/* Webkit-based browsers *\/\r\n(min--moz-device-pixel-ratio: 2),    \/* Older Firefox browsers (prior to Firefox 16) *\/\r\n(min-resolution: 2dppx),             \/* The standard way *\/\r\n(min-resolution: 192dpi) {           \/* dppx fallback *\/\r\n  \/* Retina-specific stuff here *\/\r\n}<\/pre>\n<p>[\u5efa\u8bae] \u5c3d\u53ef\u80fd\u7ed9\u51fa\u5728\u9ad8\u5206\u8fa8\u7387\u8bbe\u5907 (Retina) \u4e0b\u6548\u679c\u66f4\u4f73\u7684\u6837\u5f0f\u3002<\/p>\n<h2><strong>7 \u517c\u5bb9\u6027<\/strong><\/h2>\n<p><strong>7.1 \u5c5e\u6027\u524d\u7f00<\/strong><\/p>\n<p>[\u5efa\u8bae] \u5e26\u79c1\u6709\u524d\u7f00\u7684\u5c5e\u6027\u7531\u957f\u5230\u77ed\u6392\u5217\uff0c\u6309\u5192\u53f7\u4f4d\u7f6e\u5bf9\u9f50\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>\u6807\u51c6\u5c5e\u6027\u653e\u5728\u6700\u540e\uff0c\u6309\u5192\u53f7\u5bf9\u9f50\u65b9\u4fbf\u9605\u8bfb\uff0c\u4e5f\u4fbf\u4e8e\u5728\u7f16\u8f91\u5668\u5185\u8fdb\u884c\u591a\u884c\u7f16\u8f91\u3002<\/p>\n<p>\u5728 Sublime Text 2 \u4e2d\uff0c \u4f7f\u7528 Selection \u2192 Add Previous Line (\u2303\u21e7\u2191) \u548c Selection \u2192 Add Next Line (\u2303\u21e7\u2193)\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">.box {\r\n  -webkit-box-sizing: border-box;\r\n     -moz-box-sizing: border-box;\r\n          box-sizing: border-box;\r\n}<\/pre>\n<p><strong>7.2 Hack<\/strong><\/p>\n<p>[\u5efa\u8bae] \u9700\u8981\u6dfb\u52a0 hack \u65f6\u5e94\u5c3d\u53ef\u80fd\u8003\u8651\u662f\u5426\u53ef\u4ee5\u91c7\u7528\u5176\u4ed6\u65b9\u5f0f\u89e3\u51b3\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>\u5982\u679c\u80fd\u901a\u8fc7\u5408\u7406\u7684 HTML \u7ed3\u6784\u6216\u4f7f\u7528\u5176\u4ed6\u7684 CSS \u5b9a\u4e49\u8fbe\u5230\u7406\u60f3\u7684\u6837\u5f0f\uff0c\u5219\u4e0d\u5e94\u8be5\u4f7f\u7528 hack \u624b\u6bb5\u89e3\u51b3\u95ee\u9898\u3002\u901a\u5e38 hack \u4f1a\u5bfc\u81f4\u7ef4\u62a4\u6210\u672c\u7684\u589e\u52a0\u3002<\/p>\n<p>[\u5efa\u8bae] \u5c3d\u91cf\u4f7f\u7528 \u9009\u62e9\u5668 hack \u5904\u7406\u517c\u5bb9\u6027\uff0c\u800c\u975e \u5c5e\u6027 hack\u3002<\/p>\n<p>\u89e3\u91ca\uff1a<\/p>\n<p>\u5c3d\u91cf\u4f7f\u7528\u7b26\u5408 CSS \u8bed\u6cd5\u7684 selector hack\uff0c\u53ef\u4ee5\u907f\u514d\u4e00\u4e9b\u7b2c\u4e09\u65b9\u5e93\u65e0\u6cd5\u8bc6\u522b hack \u8bed\u6cd5\u7684\u95ee\u9898\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">\/* IE 7 *\/\r\n*:first-child + html #header {\r\n  margin-top: 3px;\r\n  padding: 5px;\r\n}\r\n\/* IE 6 *\/\r\n* html #header {\r\n  margin-top: 5px;\r\n  padding: 4px;\r\n}<\/pre>\n<p>[\u5efa\u8bae] \u5c3d\u91cf\u4f7f\u7528\u7b80\u5355\u7684 \u5c5e\u6027 hack\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre class=\"brush:php;toolbar:false\">.box {\r\n  _display: inline; \/* fix double margin *\/\r\n  float: left;\r\n  margin-left: 20px;\r\n}\r\n.container {\r\n  overflow: hidden;\r\n  *zoom: 1; \/* triggering hasLayout *\/\r\n}<\/pre>\n<p><strong>7.3 Expression<\/strong><\/p>\n<p>[\u5f3a\u5236] \u7981\u6b62\u4f7f\u7528 Expression\u3002<\/p>\n<p><strong>7.4 @import<\/strong><\/p>\n<p>[\u5f3a\u5236] \u7981\u6b62\u4f7f\u7528 @import\u3002<\/p>\n<p>\u89e3\u91ca\uff1a\u4e0e \u76f8\u6bd4, @import \u66f4\u6162\uff0c\u9700\u8981\u989d\u5916\u7684\u9875\u9762\u8bf7\u6c42\uff0c\u5e76\u4e14\u53ef\u80fd\u5f15\u53d1\u5176\u4ed6\u7684\u610f\u60f3\u4e0d\u5230\u7684\u95ee\u9898\u3002\u5e94\u8be5\u907f\u514d\u4f7f\u7528\u4ed6\u4eec\uff0c\u800c\u9009\u62e9\u5176\u4ed6\u7684\u65b9\u6848\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528\u591a\u4e2a &lt;link&gt; \u5143\u7d20<\/li>\n<li>\u4f7f\u7528 CSS \u9884\u5904\u7406\u5668\u4f8b\u5982 Sass \u6216 Less \u5c06\u6837\u5f0f\u7f16\u8bd1\u5230\u4e00\u4e2a\u6587\u4ef6\u4e2d<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fCSS\u7f16\u7801\u89c4\u8303\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8html\u4e2d\u6587\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u6863\u867d\u9488\u5bf9CSS\u8bbe\u8ba1\u7684\uff0c\u4f46\u662f\u5728\u4f7f\u7528\u5404\u79cdCSS\u7684\u9884\u7f16\u8bd1\u5668(\u5982less\u3001sass\u3001stylus\u7b49)\u65f6\uff0c\u9002\u7528\u7684\u90e8\u5206 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[105,127],"tags":[],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2624"}],"collection":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2624"}],"version-history":[{"count":1,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2624\/revisions"}],"predecessor-version":[{"id":2625,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2624\/revisions\/2625"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2624"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2624"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}