{"id":2019,"date":"2024-11-10T08:20:08","date_gmt":"2024-11-10T00:20:08","guid":{"rendered":"https:\/\/fwq.ai\/blog\/2019\/"},"modified":"2024-11-10T08:20:08","modified_gmt":"2024-11-10T00:20:08","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-css-%e5%ae%9e%e7%8e%b0%e5%85%84%e5%bc%9f%e5%85%83%e7%b4%a0%e5%ae%bd%e5%ba%a6%e8%b7%9f%e9%9a%8f%e6%9c%80%e9%95%bf%e7%9a%84%e4%b8%80%e4%b8%aa%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/2019\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 CSS \u5b9e\u73b0\u5144\u5f1f\u5143\u7d20\u5bbd\u5ea6\u8ddf\u968f\u6700\u957f\u7684\u4e00\u4e2a\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173063055896137.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 CSS \u5b9e\u73b0\u5144\u5f1f\u5143\u7d20\u5bbd\u5ea6\u8ddf\u968f\u6700\u957f\u7684\u4e00\u4e2a\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 CSS \u5b9e\u73b0\u5144\u5f1f\u5143\u7d20\u5bbd\u5ea6\u8ddf\u968f\u6700\u957f\u7684\u4e00\u4e2a\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5b9e\u73b0\u5144\u5f1f\u5143\u7d20\u5bbd\u5ea6\u8ddf\u968f\u6700\u957f\u7684\u4e00\u4e2a<\/strong><\/p>\n<p><strong>\u95ee\u9898\u63cf\u8ff0<\/strong><\/p>\n<p>\u5728html\u9875\u9762\u4e2d\uff0c\u5b58\u5728\u4e09\u4e2a\u6c34\u5e73\u7684div\u5143\u7d20\uff0c\u5206\u522b\u4e3a\u7ea2\u8272\u3001\u7070\u8272\u548c\u7eff\u8272\u80cc\u666f\u3002\u8981\u6c42\u7ea2\u8272\u548c\u7070\u8272\u5143\u7d20\u7684\u5bbd\u5ea6\u81ea\u52a8\u8ddf\u968f\u7eff\u8272\u5143\u7d20\u7684\u5bbd\u5ea6\uff0c\u5e76\u6491\u6ee1\u5b83\u4eec\u7684\u7236\u5bb9\u5668\u3002\u73b0\u6709\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>&lt;div class=\"container\"&gt;\n    &lt;div class=\"item1\"&gt;item1&lt;\/div&gt;\n    &lt;div class=\"item2\"&gt;item2&lt;\/div&gt;\n    &lt;div class=\"item3\"&gt;item3&lt;\/div&gt;\n&lt;\/div&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528 fit-content \u5c5e\u6027\u6765\u89e3\u51b3\u6b64\u95ee\u9898\u3002\u7ed9\u7236\u5bb9\u5668 contner \u6dfb\u52a0width: fit-content property\uff0c\u5373\u53ef\u5b9e\u73b0\u5144\u5f1f\u5143\u7d20\u5bbd\u5ea6\u8ddf\u968f\u6700\u957f\u7684\u4e00\u4e2a\u3002<\/p>\n<p><strong>\u4ee3\u7801\u5b9e\u73b0<\/strong><\/p>\n<pre>&lt;div class=\"wrap\"&gt;\n    &lt;div class=\"container\"&gt;\n        &lt;div class=\"item1\"&gt;item1&lt;\/div&gt;\n        &lt;div class=\"item2\"&gt;item2&lt;\/div&gt;\n        &lt;div class=\"item3\"&gt;item3&lt;\/div&gt;\n    &lt;\/div&gt;\n&lt;\/div&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>.wrap {\n    width: 100%;\n    overflow-x: auto;\n}\n\n.container {\n    width: fit-content;\n}\n\n.item1 {\n    background: red;\n}\n\n.item2 {\n    background: gray;\n}\n\n.item3 {\n    min-width: 1300px;\n    background: greenyellow;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879<\/strong><\/p>\n<p>\u4f7f\u7528 fit-content \u53ef\u80fd\u4f1a\u5bfc\u81f4\u6eda\u52a8\u6761\u51fa\u73b0\u5728\u7236\u5bb9\u5668\u4e2d\uff0c\u56e0\u6b64\u5efa\u8bae\u5728 container \u5916\u90e8\u518d\u5957\u4e00\u5c42 wrap \u5143\u7d20\uff0c\u5e76\u8bbe\u7f6e -x: auto \u5c5e\u6027\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 CSS \u5b9e\u73b0\u5144\u5f1f\u5143\u7d20\u5bbd\u5ea6\u8ddf\u968f\u6700\u957f\u7684\u4e00\u4e2a\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5b9e\u73b0\u5144\u5f1f\u5143\u7d20\u5bbd\u5ea6\u8ddf\u968f\u6700\u957f\u7684\u4e00\u4e2a \u95ee\u9898\u63cf\u8ff0 \u5728html\u9875\u9762\u4e2d\uff0c\u5b58\u5728\u4e09\u4e2a\u6c34\u5e73\u7684div\u5143\u7d20\uff0c\u5206\u522b\u4e3a\u7ea2\u8272\u3001\u7070\u8272\u548c\u7eff\u8272\u80cc\u666f\u3002\u8981\u6c42\u7ea2\u8272\u548c\u7070\u8272\u5143\u7d20\u7684\u5bbd\u5ea6\u81ea\u52a8\u8ddf\u968f\u7eff\u8272\u5143\u7d20\u7684\u5bbd\u5ea6\uff0c\u5e76\u6491\u6ee1\u5b83\u4eec\u7684\u7236\u5bb9\u5668\u3002\u73b0\u6709\u4ee3\u7801\u5982\u4e0b\uff1a &lt;div class=&#8221;container&#8221;&gt; &lt;div class=&#8221;item1&#8243;&gt;item1&lt;\/div&gt; &lt;div class=&#8221;item2&#8243;&gt;item2&lt;\/div&gt; &lt;div class=&#8221;item3&#8243;&gt;item3&lt;\/div&gt; &lt;\/div&gt; \u767b\u5f55\u540e\u590d\u5236 \u89e3\u51b3\u65b9\u6848 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u53ef\u4ee5\u4f7f\u7528 fit-content \u5c5e\u6027\u6765\u89e3\u51b3\u6b64\u95ee\u9898\u3002\u7ed9\u7236\u5bb9\u5668 contner \u6dfb\u52a0width: fit-content property\uff0c\u5373\u53ef\u5b9e\u73b0\u5144\u5f1f\u5143\u7d20\u5bbd\u5ea6\u8ddf\u968f\u6700\u957f\u7684\u4e00\u4e2a\u3002 \u4ee3\u7801\u5b9e\u73b0 &lt;div class=&#8221;wrap&#8221;&gt; &lt;div class=&#8221;container&#8221;&gt; &lt;div class=&#8221;item1&#8243;&gt;item1&lt;\/div&gt; &lt;div class=&#8221;item2&#8243;&gt;item2&lt;\/div&gt; &lt;div class=&#8221;item3&#8243;&gt;item3&lt;\/div&gt; &lt;\/div&gt; &lt;\/div&gt; \u767b\u5f55\u540e\u590d\u5236 .wrap { width: 100%; overflow-x: auto; } .container { width: fit-content; } .item1 { background: red; } .item2 { [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-2019","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2019","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=2019"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2019\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=2019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=2019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=2019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}