{"id":166,"date":"2025-11-24T16:02:31","date_gmt":"2025-11-24T08:02:31","guid":{"rendered":"https:\/\/www.52runoob.com\/?p=166"},"modified":"2025-11-24T16:02:31","modified_gmt":"2025-11-24T08:02:31","slug":"css%e5%ae%9e%e7%8e%b0%e5%85%83%e7%b4%a0%e6%92%91%e6%bb%a1%e5%89%a9%e4%bd%99%e7%a9%ba%e9%97%b4%e7%9a%84%e4%ba%94%e7%a7%8d%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.52runoob.com\/index.php\/2025\/11\/24\/css%e5%ae%9e%e7%8e%b0%e5%85%83%e7%b4%a0%e6%92%91%e6%bb%a1%e5%89%a9%e4%bd%99%e7%a9%ba%e9%97%b4%e7%9a%84%e4%ba%94%e7%a7%8d%e6%96%b9%e6%b3%95\/","title":{"rendered":"CSS\u5b9e\u73b0\u5143\u7d20\u6491\u6ee1\u5269\u4f59\u7a7a\u95f4\u7684\u4e94\u79cd\u65b9\u6cd5"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u65b9\u6cd5 1\ufe0f\u20e3 Flexbox \u5f39\u6027\u5e03\u5c40<\/h2>\n\n\n\n<p><strong>\u6838\u5fc3<\/strong>\uff1a\u4f7f\u7528 <code>flex-grow: 1<\/code> \u8ba9\u5143\u7d20\u81ea\u52a8\u586b\u5145\u7236\u5bb9\u5668\u5269\u4f59\u7a7a\u95f4\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;div class=&quot;flex-container&quot;&gt;\n  &amp;lt;div class=&quot;sidebar&quot;&gt;\u4fa7\u8fb9\u680f&amp;lt;\/div&gt;\n  &amp;lt;div class=&quot;content&quot;&gt;\u5185\u5bb9\u533a\u57df&amp;lt;\/div&gt;\n&amp;lt;\/div&gt;\n\n&amp;lt;style&gt;\n.flex-container {\n  display: flex;\n  height: 200px;\n  border: 1px solid #ccc;\n}\n.sidebar {\n  width: 100px;\n  background: lightcoral;\n}\n.content {\n  flex-grow: 1; \/* \u6491\u6ee1\u5269\u4f59\u7a7a\u95f4 *\/\n  background: lightblue;\n}\n&amp;lt;\/style&gt;\n\n<\/pre><\/div>\n\n\n<p>\u2705 <strong>\u4f18\u70b9<\/strong>\uff1a\u7b80\u5355\u3001\u54cd\u5e94\u5f0f\u3001\u6c34\u5e73\/\u5782\u76f4\u90fd\u53ef\u4f7f\u7528<br>\u26a0\ufe0f <strong>\u6ce8\u610f<\/strong>\uff1a\u7236\u5bb9\u5668\u5fc5\u987b <code>display: flex<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u65b9\u6cd5 2\ufe0f\u20e3 Grid \u5e03\u5c40<\/h2>\n\n\n\n<p><strong>\u6838\u5fc3<\/strong>\uff1a\u4f7f\u7528 <code>1fr<\/code> \u6216 <code>auto<\/code> \u586b\u5145\u5269\u4f59\u7a7a\u95f4\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;div class=&quot;grid-container&quot;&gt;\n  &amp;lt;div class=&quot;sidebar&quot;&gt;\u4fa7\u8fb9\u680f&amp;lt;\/div&gt;\n  &amp;lt;div class=&quot;content&quot;&gt;\u5185\u5bb9\u533a\u57df&amp;lt;\/div&gt;\n&amp;lt;\/div&gt;\n\n&amp;lt;style&gt;\n.grid-container {\n  display: grid;\n  grid-template-columns: 100px 1fr; \/* \u7b2c\u4e8c\u5217\u6491\u6ee1\u5269\u4f59\u7a7a\u95f4 *\/\n  height: 200px;\n}\n.sidebar {\n  background: lightcoral;\n}\n.content {\n  background: lightblue;\n}\n&amp;lt;\/style&gt;\n\n<\/pre><\/div>\n\n\n<p>\u2705 <strong>\u4f18\u70b9<\/strong>\uff1a\u7ed3\u6784\u660e\u786e\uff0c\u53ef\u63a7\u5236\u591a\u5217\/\u591a\u884c<br>\u26a0\ufe0f <strong>\u6ce8\u610f<\/strong>\uff1a\u7236\u5bb9\u5668\u9700\u8981 <code>display: grid<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u65b9\u6cd5 3\ufe0f\u20e3 \u7edd\u5bf9\u5b9a\u4f4d + left\/right\/top\/bottom<\/h2>\n\n\n\n<p><strong>\u6838\u5fc3<\/strong>\uff1a\u7edd\u5bf9\u5b9a\u4f4d\u5143\u7d20\u76f8\u5bf9\u4e8e\u7236\u5143\u7d20\u6491\u6ee1\u5269\u4f59\u7a7a\u95f4\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;div class=&quot;container&quot;&gt;\n  &amp;lt;div class=&quot;sidebar&quot;&gt;\u4fa7\u8fb9\u680f&amp;lt;\/div&gt;\n  &amp;lt;div class=&quot;content&quot;&gt;\u5185\u5bb9\u533a\u57df&amp;lt;\/div&gt;\n&amp;lt;\/div&gt;\n\n&amp;lt;style&gt;\n.container {\n  position: relative;\n  height: 200px;\n}\n.sidebar {\n  width: 100px;\n  height: 100%;\n  float: left;\n  background: lightcoral;\n}\n.content {\n  position: absolute;\n  left: 100px; \/* \u4ece\u4fa7\u8fb9\u680f\u53f3\u4fa7\u5f00\u59cb *\/\n  right: 0;\n  top: 0;\n  bottom: 0;\n  background: lightblue;\n}\n&amp;lt;\/style&gt;\n\n<\/pre><\/div>\n\n\n<p>\u2705 <strong>\u4f18\u70b9<\/strong>\uff1a\u4e0d\u4f9d\u8d56 Flex\/Grid\uff0c\u517c\u5bb9\u6027\u597d<br>\u26a0\ufe0f <strong>\u6ce8\u610f<\/strong>\uff1a\u8131\u79bb\u6587\u6863\u6d41\uff0c\u9700\u8ba1\u7b97\u504f\u79fb<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u65b9\u6cd5 4\ufe0f\u20e3 calc() \u52a8\u6001\u8ba1\u7b97\u5bbd\u5ea6<\/h2>\n\n\n\n<p><strong>\u6838\u5fc3<\/strong>\uff1a\u4f7f\u7528 <code>width: calc(100% - \u5df2\u77e5\u5143\u7d20\u5bbd\u5ea6)<\/code>\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;div class=&quot;container&quot;&gt;\n  &amp;lt;div class=&quot;sidebar&quot;&gt;\u4fa7\u8fb9\u680f&amp;lt;\/div&gt;\n  &amp;lt;div class=&quot;content&quot;&gt;\u5185\u5bb9\u533a\u57df&amp;lt;\/div&gt;\n&amp;lt;\/div&gt;\n\n&amp;lt;style&gt;\n.container {\n  height: 200px;\n}\n.sidebar {\n  float: left;\n  width: 100px;\n  height: 100%;\n  background: lightcoral;\n}\n.content {\n  float: left;\n  width: calc(100% - 100px); \/* \u5269\u4f59\u5bbd\u5ea6 *\/\n  height: 100%;\n  background: lightblue;\n}\n&amp;lt;\/style&gt;\n\n<\/pre><\/div>\n\n\n<p>\u2705 <strong>\u4f18\u70b9<\/strong>\uff1a\u7b80\u5355\u660e\u4e86<br>\u26a0\ufe0f <strong>\u6ce8\u610f<\/strong>\uff1a\u9002\u5408\u5df2\u77e5\u56fa\u5b9a\u5bbd\u5ea6\u5143\u7d20\uff0c\u4e0d\u591f\u7075\u6d3b<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u65b9\u6cd5 5\ufe0f\u20e3 Table \/ display: table-cell<\/h2>\n\n\n\n<p><strong>\u6838\u5fc3<\/strong>\uff1a\u4f7f\u7528 <code>display: table<\/code> \u548c <code>table-cell<\/code> \u81ea\u52a8\u6491\u6ee1\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;div class=&quot;table-container&quot;&gt;\n  &amp;lt;div class=&quot;sidebar&quot;&gt;\u4fa7\u8fb9\u680f&amp;lt;\/div&gt;\n  &amp;lt;div class=&quot;content&quot;&gt;\u5185\u5bb9\u533a\u57df&amp;lt;\/div&gt;\n&amp;lt;\/div&gt;\n\n&amp;lt;style&gt;\n.table-container {\n  display: table;\n  width: 100%;\n  height: 200px;\n  border: 1px solid #ccc;\n}\n.sidebar {\n  display: table-cell;\n  width: 100px;\n  background: lightcoral;\n}\n.content {\n  display: table-cell; \/* \u6491\u6ee1\u5269\u4f59\u7a7a\u95f4 *\/\n  background: lightblue;\n}\n&amp;lt;\/style&gt;\n\n<\/pre><\/div>\n\n\n<p>\u2705 <strong>\u4f18\u70b9<\/strong>\uff1a\u517c\u5bb9\u8001\u6d4f\u89c8\u5668<br>\u26a0\ufe0f <strong>\u6ce8\u610f<\/strong>\uff1a\u7ed3\u6784\u53d7\u8868\u683c\u9650\u5236\uff0c\u4e0d\u9002\u5408\u590d\u6742\u5e03\u5c40<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u603b\u7ed3\u4e0e\u5efa\u8bae<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u65b9\u6cd5<\/th><th>\u4f18\u70b9<\/th><th>\u7f3a\u70b9<\/th><th>\u9002\u7528\u573a\u666f<\/th><\/tr><\/thead><tbody><tr><td>Flexbox<\/td><td>\u7b80\u5355\u3001\u54cd\u5e94\u5f0f<\/td><td>\u7236\u5143\u7d20\u9700 flex<\/td><td>\u591a\u5217\/\u591a\u884c\u5e03\u5c40\u3001\u54cd\u5e94\u5f0f\u7f51\u9875<\/td><\/tr><tr><td>Grid<\/td><td>\u7cbe\u786e\u3001\u591a\u5217\u63a7\u5236<\/td><td>\u7236\u5143\u7d20\u9700 grid<\/td><td>\u590d\u6742\u7f51\u683c\u5e03\u5c40<\/td><\/tr><tr><td>Absolute<\/td><td>\u7cbe\u786e\u5b9a\u4f4d<\/td><td>\u8131\u79bb\u6587\u6863\u6d41<\/td><td>\u5f39\u7a97\u3001\u8986\u76d6\u5185\u5bb9<\/td><\/tr><tr><td>calc()<\/td><td>\u7b80\u5355\u660e\u4e86<\/td><td>\u5df2\u77e5\u5bbd\u5ea6\u9650\u5236<\/td><td>\u56fa\u5b9a\u4fa7\u8fb9\u680f\u5e03\u5c40<\/td><\/tr><tr><td>Table-cell<\/td><td>\u8001\u6d4f\u89c8\u5668\u652f\u6301<\/td><td>\u53d7\u8868\u683c\u9650\u5236<\/td><td>\u517c\u5bb9\u6027\u9700\u6c42\u9ad8\u7684\u9879\u76ee<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u2705 <strong>\u73b0\u4ee3\u63a8\u8350<\/strong>\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Flexbox<\/strong>\uff1a\u6c34\u5e73\/\u5782\u76f4\u5e03\u5c40\u7b80\u5355\u5feb\u901f<\/li>\n\n\n\n<li><strong>Grid<\/strong>\uff1a\u591a\u5217\/\u591a\u884c\u590d\u6742\u5e03\u5c40<\/li>\n\n\n\n<li>\u7edd\u5bf9\u5b9a\u4f4d + calc() \u4ec5\u5728\u7279\u6b8a\u573a\u666f\u4f7f\u7528<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u65b9\u6cd5 1\ufe0f\u20e3 Flexbox \u5f39\u6027\u5e03\u5c40 \u6838\u5fc3\uff1a\u4f7f\u7528 flex-grow: 1 \u8ba9&#8230; <a class=\"more-link\" href=\"https:\/\/www.52runoob.com\/index.php\/2025\/11\/24\/css%e5%ae%9e%e7%8e%b0%e5%85%83%e7%b4%a0%e6%92%91%e6%bb%a1%e5%89%a9%e4%bd%99%e7%a9%ba%e9%97%b4%e7%9a%84%e4%ba%94%e7%a7%8d%e6%96%b9%e6%b3%95\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-166","post","type-post","status-publish","format-standard","hentry","category-css"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/comments?post=166"}],"version-history":[{"count":1,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/166\/revisions"}],"predecessor-version":[{"id":167,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/166\/revisions\/167"}],"wp:attachment":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/media?parent=166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/categories?post=166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/tags?post=166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}