{"id":12500,"date":"2026-11-20T17:58:33","date_gmt":"2026-11-20T09:58:33","guid":{"rendered":"https:\/\/www.zhangxinxu.com\/wordpress\/?p=12500"},"modified":"2026-11-20T17:58:33","modified_gmt":"2026-11-20T09:58:33","slug":"ifmame-sizing-content","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2026\/11\/ifmame-sizing-content\/","title":{"rendered":"\u7ee7textarea\u4e4b\u540e\uff0ciframe\u4e5f\u81ea\u9002\u5e94\u5927\u5c0f\u5566\uff01"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=12500\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=12500<\/a><br \/>\n\u672c\u6587\u53ef\u5168\u6587\u8f6c\u8f7d\uff0c\u4f46\u9700\u8981\u4fdd\u7559\u539f\u4f5c\u8005\u3001\u51fa\u5904\u4ee5\u53ca\u6587\u4e2d\u94fe\u63a5\uff0cAI\u6293\u53d6\u4fdd\u7559\u539f\u6587\u5730\u5740\uff0c\u4efb\u4f55\u7f51\u7ad9\u5747\u53ef\u6458\u8981\u805a\u5408\uff0c\u5546\u7528\u8bf7\u8054\u7cfb\u6388\u6743\u3002<\/p>\n<h3>\u4e00\u3001textarea\u9ad8\u5ea6\u81ea\u9002\u5e94<\/h3>\n<p><code>&lt;textarea&gt;<\/code>\u591a\u884c\u6587\u672c\u57df\u8f93\u5165\u6846\u57fa\u4e8e\u5185\u5bb9\u9ad8\u5ea6\u81ea\u9002\u5e94\u4e0d\u9700\u8981JS\u53c2\u4e0e\u4e86\uff0c\u7eafCSS\u5c31\u53ef\u4ee5\u5b9e\u73b0\uff1a<\/p>\n<pre>textarea {\r\n  field-sizing: content;\r\n}<\/pre>\n<p>\u8be6\u89c1\u6b64\u6587\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2025\/10\/css-field-sizing\/\">CSS field-sizing\u5c5e\u6027\u7b80\u4ecb<\/a><\/p>\n<p>\u73b0\u5728\uff0c\u597d\u6d88\u606f\uff0c<code>&lt;iframe&gt;<\/code>\u5143\u7d20\u4e5f\u652f\u6301\u9ad8\u5ea6\u57fa\u4e8e\u5185\u5bb9\u81ea\u9002\u5e94\u4e86\u3002<\/p>\n<h3>\u4e8c\u3001iframe\u9ad8\u5ea6\u81ea\u9002\u5e94<\/h3>\n<p>\u5728\u8fc7\u53bb\uff0c<code>&lt;iframe&gt;<\/code>\u60f3\u8981\u9ad8\u5ea6\u81ea\u9002\u5e94\uff0c\u9700\u8981\u4e0e\u7236\u7a97\u53e3\u901a\u4fe1\uff0c\u7136\u540e\u4f7f\u7528JS\u5b9e\u65f6\u8bbe\u7f6e\u5176\u9ad8\u5ea6\u624d\u53ef\u4ee5\u3002<\/p>\n<p>\u73b0\u5728\uff0c\u4e0d\u9700\u8981\u4e86\uff0cCSS\u5c31\u53ef\u4ee5\u641e\u5b9a\uff0c\u5c31\u662f<code>frame-sizing<\/code>\u5c5e\u6027\u3002<\/p>\n<p>\u4f8b\u5982\u6709iframe\u5143\u7d20\uff1a<\/p>\n<pre>&lt;iframe class=\"embed\" src=\"\/comments.html\" title=\"\u8bc4\u8bba\"&gt;&lt;\/iframe&gt;<\/pre>\n<p>\u5219\u4e0b\u9762\u51e0\u884cCSS\u5c31\u53ef\u4ee5\u8ba9\u6b64iframe\u7684\u9ad8\u5ea6\u57fa\u4e8e\u91cc\u9762\u7684\u5185\u5bb9\u9ad8\u5ea6\u5448\u73b0\u4e86\uff1a<\/p>\n<pre>.embed {\r\n  width: 100%;\r\n  frame-sizing: content-height;\r\n}<\/pre>\n<p>\u773c\u89c1\u4e3a\u5b9e\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff08Chrome 154+\uff09\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/202611\/css-frame-sizing-content-demo.php\" rel=\"noopener\" target=\"_blank\">CSS frame-sizing\u8ba9iframe\u57fa\u4e8e\u5185\u5bb9\u9ad8\u5ea6\u81ea\u9002\u5e94demo<\/a><\/p>\n<p>\u6548\u679c\u5982\u4e0bMP4\u89c6\u9891\u6240\u793a\uff08\u70b9\u51fb\u64ad\u653e\uff09\uff1a<\/p>\n<p><video src=\"https:\/\/image.zhangxinxu.com\/video\/blog\/202611\/iframe-sizing.mp4\" width=\"384\" height=\"402\" controls preload=\"metadata\" mute><\/video><\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c<code>frame-sizing<\/code>\u5c5e\u6027\u60f3\u8981\u751f\u6548\uff0c\u8fd8\u9700\u8981\u8bbe\u7f6e\u5bf9\u5e94\u7684<code>&lt;meta&gt;<\/code>\u5143\u4fe1\u606f\uff0c<code>name<\/code>\u5c5e\u6027\u503c\u4e3a<code>responsive-embedded-sizing<\/code>\uff0c\u5177\u4f53\u5982\u4e0b\u4ee3\u7801\u6240\u793a\uff1a<\/p>\n<pre>&lt;!doctype html&gt;\r\n&lt;html&gt;\r\n  &lt;head&gt;\r\n    &lt;meta name=\"responsive-embedded-sizing\" content=\"allow-origins=*\"&gt;\r\n  &lt;\/head&gt;\r\n  &lt;body&gt;\r\n    ...\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<h3>\u4e09\u3001\u517c\u5bb9\u6027\u4ee5\u53ca\u5176\u4ed6<\/h3>\n<p>\u672c\u6587\u4ecb\u7ecd\u7684<code>frame-sizing<\/code>\u7279\u6027\u662f\u4e2a\u76f8\u5f53\u524d\u6cbf\u7684\u65b0\u7279\u6027\uff0c\u56e0\u6b64\u517c\u5bb9\u6027\u8fd8\u4e0d\u662f\u5f88\u597d\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202611\/2026-11-20_171909.png\" width=\"651\" height=\"231\" alt=\"frame-sizing\u517c\u5bb9\u6027\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u5509\uff0c\u6240\u4ee5\uff0c\u5927\u5bb6\u5148\u4e86\u89e3\u4e86\u89e3\u5427\u3002<\/p>\n<p>\u81f3\u4e8e\u788e\u788e\u5ff5\uff0c\u7b97\u4e86\uff0c\u80a1\u5e02\u8dcc\u6210\u8fd9\u4e2a\u6837\u5b50\uff0c\u5c31\u4e0d\u5ff5\u4e86\u3002<\/p>\n<p><strong>\u53c2\u8003\u6587\u7ae0<\/strong><\/p>\n<p><a href=\"https:\/\/developer.chrome.com\/blog\/responsive-iframes?hl=en\" rel=\"noopener\" target=\"_blank\">Responsive iframes in Chrome 154<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202611\/2026-11-20_172113.webp\" width=\"268\" height=\"155\" alt=\"\u8001\u5b9e\u5199\u4ee3\u7801\u5f88\u67af\u71e5\u5427\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u4f1a\u7ecf\u5e38\u66f4\u65b0\u77e5\u8bc6\u70b9\u4ee5\u53ca\u4fee\u6b63\u4e00\u4e9b\u9519\u8bef\uff0c\u56e0\u6b64\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u539f\u51fa\u5904\uff0c\u65b9\u4fbf\u6eaf\u6e90\uff0c\u907f\u514d\u9648\u65e7\u9519\u8bef\u77e5\u8bc6\u7684\u8bef\u5bfc\uff0c\u540c\u65f6\u6709\u66f4\u597d\u7684\u9605\u8bfb\u4f53\u9a8c\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=12500\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=12500<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202611\/2026-11-20_175545.webp\" width=\"160\" height=\"95\" alt=\"iframe\u81ea\u9002\u5e94\u9ad8\u5ea6\u5c01\u9762\u56fe\" class=\"alignright size-medium\" \/><\/p>\n<p>\u66ff\u6362\u5143\u7d20\u57fa\u4e8e\u5185\u5bb9\u9ad8\u5ea6\u81ea\u9002\u5e94\u662f\u4e2a\u8001\u5927\u96be\u95ee\u9898\uff0c\u7ee7\u53bb\u5e74textarea\u5143\u7d20\u652f\u6301\u4e86\u4e4b\u540e\uff0c\u73b0\u5728iframe\u5143\u7d20\u4e5f\u652f\u6301\u5566\uff0c\u54c8\u54c8\u54c8\uff0cCSS\u7684\u80fd\u529b\u8d8a\u6765\u8d8a\u5f3a\u4e86\uff0c\u6d88\u706d\u6bcf\u4e00\u4e2a\u4e0d\u652f\u6301\u7684\u4ea4\u4e92\u7ec6\u8282\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[2083,2186,532,242,145],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/12500"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=12500"}],"version-history":[{"count":8,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/12500\/revisions"}],"predecessor-version":[{"id":12530,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/12500\/revisions\/12530"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=12500"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=12500"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=12500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}