{"id":785,"date":"2021-10-01T15:56:29","date_gmt":"2021-10-01T07:56:29","guid":{"rendered":"http:\/\/blog.xrhoujie.com\/?p=785"},"modified":"2021-09-18T15:58:20","modified_gmt":"2021-09-18T07:58:20","slug":"%e8%bd%accss%e5%b8%83%e5%b1%80%e7%9a%84%e5%87%a0%e7%a7%8d%e6%96%b9%e5%bc%8f","status":"publish","type":"post","link":"http:\/\/blog.xrhoujie.com\/?p=785","title":{"rendered":"(\u8f6c)CSS\u5e03\u5c40\u7684\u51e0\u79cd\u65b9\u5f0f"},"content":{"rendered":"<h3>\u4e00\u3001table \u5e03\u5c40<\/h3>\n<p>CSS \u7684\u5e03\u5c40\u5e94\u8be5\u662f CSS \u4f53\u7cfb\u4e2d\u7684\u91cd\u4e2d\u4e4b\u91cd\u4e86\uff0c\u4e3b\u8981\u7684\u5e03\u5c40\u65b9\u5f0f\u6709 table \u8868\u683c\u5e03\u5c40\uff08\u65e9\u671f\uff09\uff0cfloat \u6d6e\u52a8\u5e03\u5c40\u548c flex \u5e03\u5c40\uff0c\u8fd8\u6709\u9488\u5bf9\u4e8e\u79fb\u52a8\u7aef\u7684\u54cd\u5e94\u5f0f\u5e03\u5c40\uff0c\u4e0d\u8bba\u662f\u5de5\u4f5c\u8fd8\u662f\u9762\u8bd5\u90fd\u662f\u975e\u5e38\u91cd\u8981\u7684\u77e5\u8bc6\u3002<\/p>\n<p>&nbsp;<\/p>\n<div class=\"cnblogs_code\">\n<pre>&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\"&gt;\r\n&lt;head&gt;\r\n    &lt;meta charset=\"UTF-8\"&gt;\r\n    &lt;title&gt;CSS \u5e03\u5c40&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;style&gt;\r\n.container{\r\n    height:200px;\r\n    width: 200px;\r\n}\r\n.left{\r\n    background-color: red\r\n}\r\n.right{\r\n    background-color: green\r\n}\r\n&lt;\/style&gt;\r\n&lt;body&gt;\r\n    &lt;table class=container&gt;\r\n        &lt;tbody&gt;\r\n            &lt;tr&gt;\r\n                &lt;td class=left&gt; \u5de6 &lt;\/td&gt;\r\n                &lt;td class=right&gt; \u53f3 &lt;\/td&gt;\r\n            &lt;\/tr&gt;\r\n        &lt;\/tbody&gt;\r\n    &lt;\/table&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n\r\n<\/pre>\n<\/div>\n<p>table \u7684\u7279\u6027\u51b3\u5b9a\u4e86\u5b83\u975e\u5e38\u9002\u5408\u7528\u6765\u505a\u5e03\u5c40\uff0c\u5e76\u4e14\u8868\u683c\u4e2d\u7684\u5185\u5bb9\u53ef\u4ee5\u81ea\u52a8\u5c45\u4e2d\uff0c\u8fd9\u662f\u4e4b\u524d\u7528\u7684\u7279\u522b\u591a\u7684\u4e00\u79cd\u5e03\u5c40\u65b9\u5f0f<br \/>\n\u800c\u4e14\u4e5f\u52a0\u5165\u4e86 display\uff1atable;dispaly:table-cell \u6765\u652f\u6301 teble \u5e03\u5c40<\/p>\n<p>\u4f46\u662f\u5b83\u4e5f\u6709\u81ea\u8eab\u7684\u5c40\u9650\u6027\uff0c\u6bd4\u5982 table \u6bd4\u5176\u5b83 html \u6807\u8bb0\u5360\u66f4\u591a\u7684\u5b57\u8282\uff08\u9020\u6210\u4e0b\u8f7d\u65f6\u95f4\u5ef6\u8fdf,\u5360\u7528\u670d\u52a1\u5668\u66f4\u591a\u6d41\u91cf\u8d44\u6e90\uff09\uff0ctable \u4f1a\u963b\u6321\u6d4f\u89c8\u5668\u6e32\u67d3\u5f15\u64ce\u7684\u6e32\u67d3\u987a\u5e8f\u3002(\u4f1a\u5ef6\u8fdf\u9875\u9762\u7684\u751f\u6210\u901f\u5ea6,\u8ba9\u7528\u6237\u7b49\u5f85\u66f4\u4e45\u7684\u65f6\u95f4)\uff0c\u4f46\u662f\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5f53\u91c7\u7528\u5176\u4ed6\u65b9\u5f0f\u4e0d\u80fd\u5f88\u597d\u7684\u8fbe\u5230\u81ea\u5df1\u7684\u6548\u679c\u65f6\uff0c\u91c7\u7528 table \u5e03\u5c40\u80fd\u9002\u5e94\u5f53\u524d\u573a\u666f\u3002<\/p>\n<h3>\u00a0\u4e8c\u3001flex \u5e03\u5c40<\/h3>\n<h4>2.1 \u76d2\u6a21\u578b<\/h4>\n<p>\u5728\u4ecb\u7ecd flex \u5e03\u5c40\u4e4b\u524d\uff0c\u6211\u4eec\u5148\u4e86\u89e3\u4e00\u4e0b\u76d2\u6a21\u578b\u7684\u6982\u5ff5\uff0c\u8fd9\u4e2a\u662f css \u6700\u57fa\u7840\u7684\u6982\u5ff5\uff0c\u9996\u5148\uff0c\u6211\u4eec\u5f15\u7528\u4e00\u5f20\u56fe\u6765\u89e3\u91ca<\/p>\n<p>\u8fd9\u662f\u767e\u5ea6\u767e\u79d1\u91cc\u9762\u76d2\u6a21\u578b\u7684\u4e00\u5f20\u56fe\u3002\u9996\u5148\u6700\u4e2d\u95f4\u7684\u662f content \u533a\u57df\uff0c\u5373\u6211\u4eec\u5e38\u8bf4\u7684\u5185\u5bb9\u533a\u3002\u6211\u4eec\u901a\u5e38\u8bbe\u7f6e\u7684 height \u548c width \u5c31\u662f\u8bbe\u7f6e\u7684\u8fd9\u90e8\u5206\u7684\u957f\u5ea6\u3002\u5185\u5bb9\u533a\u5916\u90e8\u662f padding \u533a\u57df\uff0c\u8fd9\u90e8\u5206\u6307\u7684\u662f\u5185\u5bb9\u533a\u5230\u8fb9\u6846\u7684\u533a\u57df\uff0c\u5373\u6211\u4eec\u5e38\u8bf4\u7684\u5185\u8fb9\u8ddd\u3002\u7136\u540e\u5c31\u662f border \u533a\uff0cborder \u533a\u672c\u8eab\u4e5f\u662f\u5360\u636e\u7a7a\u95f4\u7684\u3002\u8fb9\u6846\u5916\u9762\u662f margin \u533a\uff0c\u8fd9\u90e8\u5206\u6307\u7684\u662f\u5f53\u524d\u5143\u7d20\u4e0e\u5176\u4ed6\u5143\u7d20\u7684\u8ddd\u79bb\uff0c\u5373\u5e38\u8bf4\u7684\u5916\u8fb9\u8ddd\u3002<\/p>\n<p>\u9996\u5148\u8981\u660e\u767d\u6211\u4eec\u5e73\u5e38\u8bf4\u7684\u5bbd\u5ea6\u548c\u9ad8\u5ea6\u6307\u7684\u662f\u5185\u5bb9\u533a\u7684\u5bbd\u5ea6\u548c\u9ad8\u5ea6\u3002<\/p>\n<p>\u7136\u540e\u8ba1\u7b97\u4e00\u4e2a\u76d2\u5b50\u5360\u7528\u7684\u7a7a\u95f4\u662f content + padding + border + margin<\/p>\n<h4>2.2 display \/ poistion<\/h4>\n<p>\u8fd9\u91cc\u8fd8\u8981\u4ecb\u7ecd\u4e24\u4e2a\u5c5e\u6027\uff0cdisplay \u548c poistion<\/p>\n<p>display \u6709\u5982\u4e0b\u51e0\u4e2a\u503c<\/p>\n<ul>\n<li>block\uff08\u5143\u7d20\u8868\u73b0\u4e3a\u5757\u7ea7\u5143\u7d20\uff0c\u6709\u56fa\u5b9a\u5bbd\u9ad8\uff0c\u72ec\u5360\u4e00\u884c\uff09<\/li>\n<li>inline\uff08\u5143\u7d20\u8868\u73b0\u4e3a\u884c\u5185\u5143\u7d20\uff0c\u4e0d\u80fd\u8bbe\u7f6e\u5bbd\u9ad8\uff09<\/li>\n<li>inline-block \uff08\u5bf9\u5916\u8868\u73b0\u4e3a\u884c\u5185\u5143\u7d20\uff0c\u5bf9\u5185\u8868\u73b0\u4e3a\u5757\u7ea7\u5143\u7d20\uff093<\/li>\n<\/ul>\n<p>position \u6709\u5982\u4e0b\u51e0\u4e2a\u503c<\/p>\n<ul>\n<li>static\uff08\u9ed8\u8ba4\u60c5\u51b5\uff0c\u5b58\u5728\u6587\u6863\u6d41\u5f53\u4e2d\uff09<\/li>\n<li>relative\uff08\u6839\u636e\u5143\u7d20\u672c\u8eab\u539f\u6765\u6240\u5e94\u8be5\u5904\u7684\u4f4d\u7f6e\u504f\u79fb\uff0c\u4e0d\u4f1a\u6539\u53d8\u5e03\u5c40\u7684\u8ba1\u7b97\uff09<\/li>\n<li>absolute\uff08\u7edd\u5bf9\u5b9a\u4f4d\uff0c\u8131\u79bb\u6587\u6863\u6d41\uff0c\u4e0d\u4f1a\u5bf9\u522b\u7684\u5143\u7d20\u9020\u6210\u5f71\u54cd\uff0c\u76f8\u5bf9\u7684\u662f\u7236\u7ea7\u6700\u8fd1\u7684 relative \u6216\u8005 absolute \u5b9a\u4f4d\u5143\u7d20\uff09<\/li>\n<li>fixed\uff08\u7edd\u5bf9\u5b9a\u4f4d\uff0c\u8131\u79bb\u6587\u6863\u6d41\uff0c\u76f8\u5bf9\u4e8e\u7684\u662f\u5c4f\u5e55\uff0c\u5c31\u662f\u90a3\u4e9b\u6d6e\u52a8\u7684\u5e7f\u544a\u90a3\u6837\uff0c\u600e\u4e48\u62c9\u90fd\u56fa\u5b9a\u5728\u540c\u4e00\u4e2a\u4f4d\u7f6e\uff0c\u800c absolute \u5143\u7d20\u79bb\u5f00\u5c4f\u5e55\u5c31\u770b\u4e0d\u89c1\u4e86\uff09<\/li>\n<li>position \u7684\u5c42\u53e0\u662f\u6309\u987a\u5e8f\u5c42\u53e0\u7684\uff0c\u4e0d\u8fc7\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e z-index \u6765\u6539\u53d8\u5c42\u53e0\u987a\u5e8f\uff0c\u53ea\u6709 relative\uff0cabsolute\uff0cfixed \u53ef\u4ee5\u8bbe\u7f6e z-index\u3002<\/li>\n<\/ul>\n<h4>2.3 flexbox \u5e03\u5c40<\/h4>\n<p>flexbox \u5e03\u5c40\u5373\u5f39\u6027\u76d2\u5b50\u5e03\u5c40\uff0c\u5b83\u7684\u7279\u70b9\u662f\u76d2\u5b50\u672c\u6765\u5c31\u662f\u5e76\u5217\u7684\uff0c\u53ea\u9700\u8981\u6307\u5b9a\u5bbd\u5ea6\uff0c\u6765\u770b\u4e00\u4e2a\u7ecf\u5178\u7684\u4e09\u680f\u5e03\u5c40\u7684\u4f8b\u5b50<\/p>\n<div class=\"cnblogs_code\">\n<div class=\"cnblogs_code_toolbar\"><\/div>\n<pre>&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\"&gt;\r\n&lt;head&gt;\r\n    &lt;meta charset=\"UTF-8\"&gt;\r\n    &lt;title&gt;CSS \u5e03\u5c40&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;style&gt;\r\n.container{\r\n    height:200px;\r\n    width: 200px;\r\n    display: flex\r\n}\r\n.left{\r\n    background-color: red; \r\n    flex: 1;\r\n}\r\n.middle{\r\n    background-color: yellow; \r\n    flex: 1;    \r\n}\r\n.right{\r\n    background-color: green;\r\n    flex: 1;\r\n}\r\n&lt;\/style&gt;\r\n&lt;body&gt;\r\n    &lt;div class=container&gt;\r\n        &lt;div class=left&gt;&lt;\/div&gt;\r\n        &lt;div class=middle&gt;&lt;\/div&gt;\r\n        &lt;div class=right&gt;&lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<\/div>\n<p><img class=\"medium-zoom-image\" src=\"https:\/\/img2020.cnblogs.com\/blog\/731956\/202006\/731956-20200614141619033-2020441292.png\" alt=\"\" \/><\/p>\n<p>\u6709\u65f6\u6211\u4eec\u53ef\u80fd\u9700\u8981\u4e24\u8fb9\u5b9a\u5bbd\uff0c\u4e2d\u95f4\u81ea\u9002\u5e94\uff0c\u90a3\u4e48\u53ef\u4ee5\u8fd9\u6837\u5199<\/p>\n<p><img class=\"medium-zoom-image\" src=\"https:\/\/img2020.cnblogs.com\/blog\/731956\/202006\/731956-20200614141752670-502538604.png\" alt=\"\" \/><\/p>\n<h3>\u4e09\u3001 float \u5e03\u5c40<\/h3>\n<p>float \u5e03\u5c40\u5e94\u8be5\u662f\u76ee\u524d\u5404\u5927\u7f51\u7ad9\u7528\u7684\u6700\u591a\u7684\u4e00\u79cd\u5e03\u5c40\u65b9\u5f0f\u4e86\uff0c\u4f46\u662f\u4e5f\u7279\u522b\u590d\u6742\uff0c\u8fd9\u91cc\u8be6\u7ec6\u8bb2\u4e00\u4e0b<\/p>\n<p>\u9996\u5148\uff0c\u4ec0\u4e48\u662f\u6d6e\u52a8\uff1f<\/p>\n<p>\u6d6e\u52a8\u5143\u7d20\u662f\u8131\u79bb\u6587\u6863\u6d41\u7684\uff0c\u4f46\u4e0d\u8131\u79bb\u6587\u672c\u6d41\uff0c\u8fd9\u662f\u4ec0\u4e48\u610f\u601d\u5462\uff0c\u7528\u8fc7 word \u7684\u5e94\u8be5\u77e5\u9053\u6709\u4e00\u79cd\u56fe\u7247\u73af\u7ed5\u7684\u65b9\u5f0f\u662f\u6587\u5b57\u73af\u7ed5\u5427\uff0c\u5c31\u662f\u8fd9\u79cd\u6548\u679c\u3002<\/p>\n<p>\u90a3\u4e48\u5b83\u6709\u4ec0\u4e48\u7279\u70b9\u5462<\/p>\n<ul>\n<li>\u5bf9\u81ea\u8eab\u7684\u5f71\u54cd<\/li>\n<\/ul>\n<ol>\n<li>float \u5143\u7d20\u53ef\u4ee5\u5f62\u6210\u5757\uff0c\u5982 span \u5143\u7d20\u3002\u53ef\u4ee5\u8ba9\u884c\u5185\u5143\u7d20\u4e5f\u62e5\u6709\u5bbd\u548c\u9ad8\uff0c\u56e0\u4e3a\u5757\u7ea7\u5143\u7d20\u5177\u6709\u5bbd\u9ad8<\/li>\n<li>\u6d6e\u52a8\u5143\u7d20\u7684\u4f4d\u7f6e\u5c3d\u91cf\u9760\u4e0a<\/li>\n<li>\u5c3d\u91cf\u9760\u5de6\uff08float:left\uff09\u6216\u53f3\uff08float:right\uff09\uff0c\u5982\u679c\u90a3\u4e00\u884c\u6ee1\u8db3\u4e0d\u4e86\u6d6e\u52a8\u5143\u7d20\u7684\u5bbd\u5ea6\u8981\u6c42\uff0c\u5219\u5143\u7d20\u4f1a\u5f80\u4e0b\u6389<\/li>\n<\/ol>\n<ul>\n<li>\u5bf9\u5144\u5f1f\u5143\u7d20\u7684\u5f71\u54cd<\/li>\n<\/ul>\n<ol>\n<li>\u4e0d\u5f71\u54cd\u5176\u4ed6\u5757\u7ea7\u5143\u7d20\u7684\u4f4d\u7f6e<\/li>\n<li>\u5f71\u54cd\u5176\u4ed6\u5757\u7ea7\u5143\u7d20\u7684\u6587\u672c<\/li>\n<li>\u4e0a\u9762\u8d34\u975e float \u5143\u7d20<\/li>\n<li>\u65c1\u8fb9\u8d34 float \u5143\u7d20\u6216\u8005\u8fb9\u6846<\/li>\n<\/ol>\n<ul>\n<li>\u5bf9\u7236\u7ea7\u5143\u7d20\u7684\u5f71\u54cd<\/li>\n<\/ul>\n<ol>\n<li>\u4ece\u5e03\u5c40\u4e0a \u201c\u6d88\u5931\u201d<\/li>\n<li>\u9ad8\u5ea6\u584c\u9677<\/li>\n<\/ol>\n<h3 id=\"4-\u54cd\u5e94\u5f0f\u5e03\u5c40\">\u56db\u3001\u54cd\u5e94\u5f0f\u5e03\u5c40<\/h3>\n<h4 id=\"41-meta-\u6807\u7b7e\">4.1 meta \u6807\u7b7e<\/h4>\n<p>\u6700\u7b80\u5355\u7684\u5904\u7406\u65b9\u5f0f\u662f\u52a0\u4e0a\u4e00\u4e2a meta \u6807\u7b7e<\/p>\n<div class=\"cnblogs_code\">\n<pre>&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"&gt;<\/pre>\n<\/div>\n<p>\u5176\u4e2d\uff0cwidth = device-width \u8fd9\u4e00\u53e5\u7684\u610f\u601d\u662f\u8ba9\u9875\u9762\u7684\u5bbd\u5ea6\u7b49\u4e8e\u5c4f\u5e55\u7684\u5bbd\u5ea6<\/p>\n<h4>4.2 \u4f7f\u7528 rem<\/h4>\n<p>rem \u6307\u7684\u662f html \u5143\u7d20\u7684 font-size\uff0chtml \u5143\u7d20\u7684 font-size \u9ed8\u8ba4\u662f 16px\uff0c\u6240\u4ee5 1 rem = 16px\uff1b\u7136\u540e\u6839\u636e rem \u6765\u8ba1\u7b97\u5404\u4e2a\u5143\u7d20\u7684\u5bbd\u9ad8\uff0c\u7136\u540e\u914d\u5408 media query \u5c31\u53ef\u4ee5\u5b9e\u73b0\u81ea\u9002\u5e94\u3002<\/p>\n<h4>4.3 media query<\/h4>\n<div class=\"cnblogs_code\">\n<pre>@media screen and (max-width: 360px) {  \r\n     html { font-size: 12px;    }\r\n}<\/pre>\n<\/div>\n<p>\u610f\u601d\u5c31\u662f\uff1a \u5f53\u5c4f\u5e55\u7684\u5bbd\u5ea6\u5c0f\u4e8e\u7b49\u4e8e 360 px \u7684\u65f6\u5019 html \u7684\u5b57\u4f53\u5927\u5c0f\u4e3a 12 px\u3002<\/p>\n<p>\u6709\u4e00\u4e2a\u9700\u8981\u6ce8\u610f\u7684\u70b9\u662f\u8303\u56f4\u5927\u7684\u8981\u653e\u5728\u4e0a\u9762\uff0c\u8303\u56f4\u5c0f\u7684\u653e\u5728\u4e0b\u9762\u3002\u5047\u8bbe\u6709\u4e24\u4e2a\u6837\u5f0f\uff0c\u4e00\u4e2a\u9002\u5e94 360px \u4ee5\u4e0b\uff0c\u4e00\u4e2a\u9002\u5e94 640px \u4ee5\u4e0b\uff0c\u5982\u679c 360px \u7684\u653e\u5728\u4e0a\u9762\uff0c\u4f46\u662f\u5c0f\u4e8e 360px \u540c\u6837\u6ee1\u8db3\u5c0f\u4e8e 640px\uff0c\u8fd9\u5c31\u4e0d\u662f\u6211\u4eec\u60f3\u8981\u7684\u7ed3\u679c\u4e86\uff0c\u6240\u4ee5\u8303\u56f4\u5927\u7684\u9700\u8981\u653e\u5728\u4e0a\u9762\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001table \u5e03\u5c40 CSS \u7684\u5e03\u5c40\u5e94\u8be5\u662f CSS \u4f53\u7cfb\u4e2d\u7684\u91cd\u4e2d\u4e4b\u91cd\u4e86\uff0c\u4e3b\u8981\u7684\u5e03\u5c40\u65b9\u5f0f\u6709 table \u8868\u683c\u5e03\u5c40 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":180,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[19],"_links":{"self":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/785"}],"collection":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=785"}],"version-history":[{"count":1,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/785\/revisions"}],"predecessor-version":[{"id":786,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/785\/revisions\/786"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/media\/180"}],"wp:attachment":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=785"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}