﻿{"id":883,"date":"2014-04-09T17:21:00","date_gmt":"2014-04-09T09:21:00","guid":{"rendered":"http:\/\/notes.zerobox.org\/?p=883"},"modified":"2014-04-09T17:24:17","modified_gmt":"2014-04-09T09:24:17","slug":"%e5%93%8d%e5%ba%94%e5%bc%8f%e8%ae%be%e8%ae%a1%e7%ae%80%e6%98%93%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"http:\/\/zerobox.org\/notes\/883.html","title":{"rendered":"\u54cd\u5e94\u5f0f\u8bbe\u8ba1\u7b80\u6613\u6307\u5357"},"content":{"rendered":"<p>\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528\u54cd\u5e94\u5f0f\u8bbe\u8ba1\uff1f<br \/>\n\u6211\u4eec\u60f3\u8ba9\u6211\u4eec\u7684\u7f51\u7ad9\u901a\u8fc7\u54cd\u5e94\u7528\u6237\u7684\u884c\u4e3a\u3001\u8bbe\u5907\u7684\u5c4f\u5e55\u5927\u5c0f\u548c\u5c4f\u5e55\u65b9\u5411\uff0c\u4ece\u800c\u5728\u6240\u6709\u8bbe\u5907\u4e0a\u90fd\u80fd\u7528\u3002<\/p>\n<p>\u4e00\u4e2a\u788e\u7247\u5316\u7684\u4e16\u754c<br \/>\n\u622a\u6b622013\u5e74\uff0c\u6709\u6210\u5343\u4e0a\u4e07\u79cd\u4e0d\u540c\u7684\u8bbe\u5907\u5728\u6d4f\u89c8\u7f51\u9875\uff0c\u6240\u4ee5\u6211\u4eec\u4e0d\u53ef\u80fd\u8bbe\u8ba1\u51fa\u9002\u5e94\u6240\u6709\u5c4f\u5e55\u5927\u5c0f\u7684\u7f51\u9875\u3002\u76f8\u53cd\uff0c\u6211\u4eec\u5fc5\u987b\u5f97\u91c7\u7528\u4e00\u79cd\u66f4\u52a0\u6d41\u7545\u7684\u65b9\u5f0f\u53bb\u8bbe\u8ba1\u3002<\/p>\n<p>\u79fb\u52a8\u4f18\u5148<br \/>\n\u6700\u8fd1\u4e00\u4e2a\u6bd4\u8f83\u706b\u7684\u8bcd\u53eb\u79fb\u52a8\u4f18\u5148\u3002\u5b83\u7684\u610f\u601d\u662f\uff0c\u5148\u4e3a\u79fb\u52a8\u7aef\u8bbe\u8ba1\u6837\u5f0f\uff0c\u7136\u540e\u518d\u6839\u636e\u9700\u6c42\u53bb\u4f18\u5316\u66f4\u5927\u5c4f\u5e55\u7684\u6837\u5f0f\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c\u5047\u5982\u4f60\u628a\u79fb\u52a8\u7aef\u6837\u5f0f\u5f53\u6210\u7f51\u7ad9\u7684\u9ed8\u8ba4\u6837\u5f0f\uff0c\u4e14\u4ee5\u540e\u4e0d\u7528\u53bb\u4f18\u5316\u5b83\uff0c\u4e00\u6b65\u5230\u4f4d\u3002\u90a3\u5c31\u66f4\u7701\u4e8b\u4e86\uff01<\/p>\n<p>\u201c\u5047\u5b9a\u9ed8\u8ba4\u4f7f\u7528\u4e00\u4e2a\u7075\u6d3b\u4f46\u7b80\u5355\u7684\u5e03\u5c40\uff0c\u4f60\u7684\u786e\u53ef\u4ee5\u9002\u914d\u5404\u79cd\u6d4f\u89c8\u5668\uff0c\u4f46\u8fd9\u8fd8\u4e0d\u7b97\u662f\u5b8c\u5168\u505a\u5230\u4e86\u54cd\u5e94\u5f0f\u5e03\u5c40\u3002\u6240\u4ee5\u5f53\u6211\u4eec\u8c08\u8bba\u300c\u79fb\u52a8\u4f18\u5148\u300d\uff0c\u5b9e\u9645\u4e0a\u662f\u5728\u8bf4\u300c\u6e10\u8fdb\u589e\u5f3a\u300d\u3002\u201d \u2014Ethan Marcotte<\/p>\n<p>\u7528 Min-width \u8fdb\u884c\u5a92\u4f53\u67e5\u8be2\uff08 Media Queries \uff09<br \/>\n\u73b0\u5728\u6765\u4ecb\u7ecd\u4e00\u79cd\u7279\u522b\u7684\u5e03\u5c40\u65b9\u5f0f\u3002 \u901a\u8fc7 min-width \u6765\u754c\u5b9a\u4e0d\u540c\u5c4f\u5e55\u8be5\u5982\u4f55\u5e03\u5c40\u3002\u5b83\u80fd\u5c31\u8fd1\u68c0\u6d4b\u51fa\u4e0d\u540c\u8bbe\u5907\u7684\u5c4f\u5e55\u5927\u5c0f\uff08\u5373 media queries\uff0c\u53ef\u76f4\u8bd1\u4e3a\u5a92\u4f53\u67e5\u8be2\uff09\uff0c\u6bd4\u5728\u6837\u5f0f\u8868\u672b\u5c3e\u6216\u4e00\u4e2a\u5355\u72ec\u6587\u4ef6\u4e2d\u5904\u7406\u66f4\u7b80\u5355\u3002<\/p>\n<p>\/* Small screens (default) *\/<br \/>\nhtml { font-size: 100%; }<\/p>\n<p>\/* Medium screens (640px) *\/<br \/>\n@media (min-width: 40rem) {<br \/>\n  html { font-size: 112%; }<br \/>\n}<\/p>\n<p>\/* Large screens (1024px) *\/<br \/>\n@media (min-width: 64rem) {<br \/>\n  html { font-size: 120%; }<br \/>\n}<br \/>\n\u6b65\u9aa4<br \/>\n1. \u4e0d\u662f\u6240\u6709\u6d4f\u89c8\u5668\u751f\u800c\u5e73\u7b49<br \/>\n\u540c\u4e00\u4efd CSS\uff0c\u4e0d\u540c\u6d4f\u89c8\u5668\u6e32\u67d3\u51fa\u6765\u7684\u6548\u679c\u4e0d\u4e00\u6837\u3002\u4e3a\u4e86\u907f\u514d\u51fa\u73b0\u8fd9\u79cd\u60c5\u51b5\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u7c7b\u4f3c Normalize.css \u8fd9\u79cd\u66f4\u597d\u7684 CSS \u6765\u5e2e\u52a9\u4f60\u5b9e\u73b0\u8de8\u6d4f\u89c8\u5668\u663e\u793a\u3002\u5f53\u7136\uff0c\u4f60\u8981\u628a\u8fd9\u4efdCSS\u653e\u5728\u4f60\u6837\u5f0f\u8868\u6700\u524d\u9762\u3002<\/p>\n<link rel=\"stylesheet\" href=\"\/css\/normalize.css\">\n<link rel=\"stylesheet\" href=\"\/css\/grid.css\">\n2. \u5728 Viewport \u91cc\u52a0 Meta \u6807\u7b7e<br \/>\n\u5728\u4f60 HTML \u7684 head \u4ee3\u7801\u91cc\u6dfb\u52a0 Meta \u6807\u7b7e\u3002\u5b83\u53ef\u4ee5\u4f7f media queries \u5728\u4e0d\u540c\u8bbe\u5907\u4e0a\u8d77\u4f5c\u7528<\/p>\n<p><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><br \/>\n3. CSS \u76d2\u6a21\u578b<br \/>\n\u5728 CSS \u6587\u4ef6\u6700\u9876\u7aef\u8bbe\u7f6e box-sizing\u3002\u8fd0\u7528 * \u901a\u7528\u9009\u62e9\u5668\u4f7f\u5176\u5e94\u7528\u5230\u9875\u9762\u7684\u6bcf\u4e2a\u5143\u7d20\u4e0a\u3002<\/p>\n<p>*, *:before, *:after {<br \/>\n  -moz-box-sizing: border-box;<br \/>\n  -webkit-box-sizing: border-box;<br \/>\n  box-sizing: border-box;<br \/>\n}<br \/>\n4. \u521b\u5efa\u5bb9\u5668<br \/>\n\u4e00\u4e2a\u5bb9\u5668\u5c06\u5305\u542b\u9875\u9762\u6240\u6709\u6807\u7b7e\uff0c\u5e76\u63a7\u5236\u9875\u9762\u6700\u5927\u5bbd\u5ea6. \u8fd0\u7528\u5bb9\u5668\uff0c\u8ba9\u6211\u4eec\u7684\u54cd\u5e94\u5f0f\u8bbe\u8ba1\u66f4\u8fdb\u4e86\u4e00\u6b65\uff01<\/p>\n<p>.container {<br \/>\n  margin: 0 auto;<br \/>\n  max-width: 48rem;<br \/>\n  width: 90%;<br \/>\n}<\/p>\n<div class=\"container\">\n  <!-- Your Content -->\n<\/div>\n<p>5. \u521b\u5efa\u5217<br \/>\n\u5728\u79fb\u52a8\u4f18\u5148\u91cc\uff0c\u5217\u9ed8\u8ba4\u5747\u662f block \u7ea7\u522b\u7684\uff08\u53ef\u4ee5\u5360\u6ee1\u6574\u884c\u7684\u5bbd\u5ea6\uff09\u3002\u4e0d\u9700\u8981\u989d\u5916\u7684\u6837\u5f0f\uff01<\/p>\n<div class=\"container\">\n<div class=\"column\">\n    <!-- Your Content -->\n  <\/div>\n<\/div>\n<p>6. \u521b\u5efa\u5217\u5bbd<br \/>\n\u5728\u5927\u5c4f\u4e2d\uff0c\u7528 float: left \u5c06\u5217\u6c34\u5e73\u6392\u5217\u3002\u7136\u540e\u8fd0\u7528 padding \u8bbe\u7f6e\u76f8\u90bb\u4e24\u5217\u4e4b\u95f4\u7684\u95f4\u9699\uff0c\u5fd8\u6389\u4f20\u7edf\u7684margin\u5427\u3002<\/p>\n<div class=\"container\">\n<div class=\"row\">\n<div class=\"column half\">\n      <!-- Your Content -->\n    <\/div>\n<div class=\"column half\">\n      <!-- Your Content -->\n    <\/div>\n<\/p><\/div>\n<\/div>\n<p>@media (min-width: 40rem) {<br \/>\n  .column {<br \/>\n    float: left;<br \/>\n    padding-left: 1rem;<br \/>\n    padding-right: 1rem;<br \/>\n  }<\/p>\n<p>  .column.full { width: 100%; }<br \/>\n  .column.two-thirds { width: 66.7%; }<br \/>\n  .column.half { width: 50%; }<br \/>\n  .column.third { width: 33.3%; }<br \/>\n  .column.fourth { width: 24.95%; }<br \/>\n  .column.flow-opposite { float: right; }<br \/>\n}<br \/>\n7. \u521b\u5efa\u884c<br \/>\n\u5217\u5e94\u8be5\u5305\u88f9\u5728\u884c\u5185\uff0c\u4ee5\u907f\u514d\u5176\u4ed6\u5143\u7d20\u5806\u653e\u5728\u5176\u65c1\u8fb9\u9020\u6210\u5e03\u5c40\u6df7\u4e71\u3002\u5426\u5219\u5c31\u4f1a\u51fa\u73b0\u5e7f\u4e3a\u4eba\u77e5\u7684 clearing \u95ee\u9898\u3002\u51fa\u73b0\u4e4b\u540e\u53ef\u4ee5\u4f7f\u7528\u7531 Nicolas Gallagher \u53d1\u660e\u7684 clearfix \u89e3\u51b3\u3002<\/p>\n<div class=\"container\">\n<div class=\"row clearfix\">\n<div class=\"column half\">\n      <!-- Your Content -->\n    <\/div>\n<div class=\"column half\">\n      <!-- Your Content -->\n    <\/div>\n<\/p><\/div>\n<div class=\"row clearfix\">\n<div class=\"column half\">\n      <!-- Your Content -->\n    <\/div>\n<div class=\"column half\">\n      <!-- Your Content -->\n    <\/div>\n<\/p><\/div>\n<\/div>\n<p>.clearfix:before,<br \/>\n.clearfix:after {<br \/>\n  content: &#8221; &#8220;;<br \/>\n  display: table;<br \/>\n}<\/p>\n<p>.clearfix:after {<br \/>\n  clear: both;<br \/>\n}<\/p>\n<p>.clearfix {<br \/>\n  *zoom: 1;<br \/>\n}<br \/>\n\u76f8\u5bf9\u6d41\uff08 Flow Opposite \uff09<br \/>\n\u7ed9\u4f60\u60f3\u8ba9\u5b83\u5728\u79fb\u52a8\u7aef\u4f18\u5148\u663e\u793a\uff0c\u800c\u5728\u5927\u5c4f\u5e55\u4e2d\u53f3\u4fa7\u663e\u793a\u7684\u5217\uff0c\u6dfb\u52a0 .flow-opposite \u7c7b\u3002<\/p>\n<div class=\"container\">\n<div class=\"row clearfix\">\n<div class=\"column half flow-opposite\">\n      <!-- Your Content -->\n    <\/div>\n<div class=\"column half\">\n      <!-- Your Content -->\n    <\/div>\n<\/p><\/div>\n<\/div>\n<p>@media (min-width: 40rem) {<br \/>\n  .column.flow-opposite { float: right; }<br \/>\n}<br \/>\n\u5ef6\u4f38\u9605\u8bfb<br \/>\nA Book Apart: Mobile First<br \/>\nA Book Apart: Responsive Web Design<br \/>\nBeginner\u2019s Guide to Respons<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528\u54cd\u5e94\u5f0f\u8bbe\u8ba1\uff1f \u6211\u4eec\u60f3\u8ba9\u6211\u4eec\u7684\u7f51\u7ad9\u901a\u8fc7\u54cd\u5e94\u7528\u6237\u7684\u884c\u4e3a\u3001\u8bbe\u5907\u7684\u5c4f\u5e55\u5927\u5c0f\u548c &hellip;<\/p>\n<p class=\"read-more\"><a href=\"http:\/\/zerobox.org\/notes\/883.html\">\u7ee7\u7eed\u9605\u8bfb &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[222],"class_list":["post-883","post","type-post","status-publish","format-standard","hentry","tag-222"],"views":496,"_links":{"self":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/posts\/883","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/comments?post=883"}],"version-history":[{"count":0,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/posts\/883\/revisions"}],"wp:attachment":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/media?parent=883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/categories?post=883"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/tags?post=883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}