{"id":28045,"date":"2024-11-24T08:51:38","date_gmt":"2024-11-24T00:51:38","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28045\/"},"modified":"2024-11-24T08:51:38","modified_gmt":"2024-11-24T00:51:38","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-overflow-auto-%e5%ae%9e%e7%8e%b0%e8%b6%85%e5%87%ba-div-%e7%95%8c%e9%9d%a2%e7%9a%84%e5%86%85%e5%ae%b9%e6%bb%9a%e5%8a%a8%e5%b1%95%e7%a4%ba%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28045\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 overflow: &#8216;auto&#8217; \u5b9e\u73b0\u8d85\u51fa DIV \u754c\u9762\u7684\u5185\u5bb9\u6eda\u52a8\u5c55\u793a\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173138513655043.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 overflow: &#8216;auto&#8217; \u5b9e\u73b0\u8d85\u51fa DIV \u754c\u9762\u7684\u5185\u5bb9\u6eda\u52a8\u5c55\u793a\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 overflow: &#8216;auto&#8217; \u5b9e\u73b0\u8d85\u51fa DIV \u754c\u9762\u7684\u5185\u5bb9\u6eda\u52a8\u5c55\u793a\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u8d85\u51fa div \u754c\u9762\u65f6\u7684\u6ed1\u6761\u5c55\u793a<\/strong><\/p>\n<p>\u5f53\u5b50\u7ec4\u4ef6 <\/p>\n<pre>subcontainer<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u4e2d\u7684 <\/p>\n<pre>data<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u5185\u5bb9\u8fc7\u591a\u65f6\uff0c\u5b83\u9700\u8981\u901a\u8fc7\u6ea2\u51fa\u6eda\u52a8 <\/p>\n<pre>overflow: 'auto'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u6765\u5c55\u793a\u3002 <\/p>\n<p>\u4fee\u6539\u540e\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>return (\n    &lt;div style={{borderRadius: '8px', border: '2px dashed #333', height: props.height, overflow: 'auto'}}&gt;\n        &lt;div style={{ textAlign: 'left' }}&gt;\n            &lt;label&gt;{props.title}&lt;\/label&gt;\n        &lt;\/div&gt;\n        &lt;div&gt;\n            {props.data.map((item, index) =&gt; (\n                &lt;div\n                    key={`${index}-${item.type}-${item.value} `}\n                    style={{\n                        float: 'left',\n                        display: 'inline-block',\n                        borderRadius: '6px',\n                        border: '2px solid #000',\n                        margin: '8px',\n                        padding: '4px',\n                        backgroundColor: item.selected ? '#39fe40' : ''\n                    }}\n                &gt;\n                    {item.value}\n                &lt;\/div&gt;\n            ))}\n        &lt;\/div&gt;\n    &lt;\/div&gt;\n);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u6dfb\u52a0 <\/p>\n<pre>overflow: 'auto'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \uff0c\u5f53\u5185\u5bb9\u8d85\u51fa <\/p>\n<pre>div<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u754c\u9762\u65f6\uff0c\u5b83\u5c06\u5141\u8bb8\u5782\u76f4\u6eda\u52a8\uff0c\u4ece\u800c\u53ef\u4ee5\u4e0a\u4e0b\u62d6\u52a8\u6ed1\u6761\u6765\u5c55\u793a\u5185\u5bb9\u3002 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 : &#8216;auto&#8217; \u5b9e\u73b0\u8d85\u51fa DIV \u754c\u9762\u7684\u5185\u5bb9\u6eda\u52a8\u5c55\u793a\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>\u8d85\u51fa div \u754c\u9762\u65f6\u7684\u6ed1\u6761\u5c55\u793a \u5f53\u5b50\u7ec4\u4ef6 subcontainer \u767b\u5f55\u540e\u590d\u5236 \u4e2d\u7684 data \u767b\u5f55\u540e\u590d\u5236 \u5185\u5bb9\u8fc7\u591a\u65f6\uff0c\u5b83\u9700\u8981\u901a\u8fc7\u6ea2\u51fa\u6eda\u52a8 overflow: &#8216;auto&#8217; \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u6765\u5c55\u793a\u3002 \u4fee\u6539\u540e\u7684\u4ee3\u7801\u5982\u4e0b\uff1a return ( &lt;div style={{borderRadius: &#8216;8px&#8217;, border: &#8216;2px dashed #333&#8217;, height: props.height, overflow: &#8216;auto&#8217;}}&gt; &lt;div style={{ textAlign: &#8216;left&#8217; }}&gt; &lt;label&gt;{props.title}&lt;\/label&gt; &lt;\/div&gt; &lt;div&gt; {props.data.map((item, index) =&gt; ( &lt;div key={`${index}-${item.type}-${item.value} `} style={{ float: &#8216;left&#8217;, display: &#8216;inline-block&#8217;, borderRadius: &#8216;6px&#8217;, border: &#8216;2px solid #000&#8217;, [&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-28045","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28045","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=28045"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28045\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28045"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28045"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28045"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}