{"id":52933,"date":"2024-12-03T15:27:37","date_gmt":"2024-12-03T07:27:37","guid":{"rendered":"https:\/\/fwq.ai\/blog\/52933\/"},"modified":"2024-12-03T15:27:37","modified_gmt":"2024-12-03T07:27:37","slug":"%e5%a6%82%e4%bd%95%e8%ae%a9%e5%9b%be%e7%89%87%e7%ad%89%e6%af%94%e4%be%8b%e5%ae%8c%e6%95%b4%e6%98%be%e7%a4%ba%ef%bc%8c%e6%97%a2%e4%b8%8d%e8%a3%81%e5%89%aa%e4%b9%9f%e4%b8%8d%e7%95%99%e7%99%bd%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/52933\/","title":{"rendered":"\u5982\u4f55\u8ba9\u56fe\u7247\u7b49\u6bd4\u4f8b\u5b8c\u6574\u663e\u793a\uff0c\u65e2\u4e0d\u88c1\u526a\u4e5f\u4e0d\u7559\u767d\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u5982\u4f55\u8ba9\u56fe\u7247\u7b49\u6bd4\u4f8b\u5b8c\u6574\u663e\u793a\uff0c\u65e2\u4e0d\u88c1\u526a\u4e5f\u4e0d\u7559\u767d\uff1f<\/h1>\n<p>\u7c73\u4e91\u4eca\u5929\u5c06\u7ed9\u5927\u5bb6\u5e26\u6765<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5982\u4f55\u8ba9\u56fe\u7247\u7b49\u6bd4\u4f8b\u5b8c\u6574\u663e\u793a\uff0c\u65e2\u4e0d\u88c1\u526a\u4e5f\u4e0d\u7559\u767d\uff1f\u300b<\/span>\uff0c\u611f\u5174\u8da3\u7684\u670b\u53cb\u8bf7\u7ee7\u7eed\u770b\u4e0b\u53bb\u5427\uff01\u4ee5\u4e0b\u5185\u5bb9\u5c06\u4f1a\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u662f\u6b63\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u6216\u8005\u5df2\u7ecf\u662f\u5927\u4f6c\u7ea7\u522b\u4e86\uff0c\u90fd\u975e\u5e38\u6b22\u8fce\u4e5f\u5e0c\u671b\u5927\u5bb6\u90fd\u80fd\u7ed9\u6211\u5efa\u8bae\u8bc4\u8bba\u54c8~\u5e0c\u671b\u80fd\u5e2e\u52a9\u5230\u5927\u5bb6\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241124\/1732453064674322c89fe3c.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u8ba9\u56fe\u7247\u7b49\u6bd4\u4f8b\u5b8c\u6574\u663e\u793a\uff0c\u65e2\u4e0d\u88c1\u526a\u4e5f\u4e0d\u7559\u767d\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u8ba9\u56fe\u7247\u7b49\u6bd4\u4f8b\u5b8c\u6574\u663e\u793a\uff0c\u65e2\u4e0d\u88c1\u526a\u4e5f\u4e0d\u7559\u767d\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u56fe\u7247\u7f29\u653e\u4e0d\u53d8\u5f62\u4e14\u5185\u5bb9\u5b8c\u6574\u663e\u793a\u4e0d\u88c1\u526a\u7684\u65b9\u6cd5<\/strong><\/p>\n<p>\u5982\u4f55\u8ba9\u56fe\u7247\u6309\u7167\u7b49\u6bd4\u4f8b\u5b8c\u6574\u663e\u793a\uff0c\u65e2\u4e0d\u88c1\u526a\u4e5f\u4e0d\u7559\u767d\uff1f\u8fd9\u662f\u4e2a\u5e38\u89c1\u7684\u95ee\u9898\uff0c\u5c24\u5176\u662f\u5f53\u56fe\u7247\u6bd4\u4f8b\u662f\u56fa\u5b9a\u7684\u60c5\u51b5\u4e0b\u3002<\/p>\n<p>\u4f7f\u7528 object-fit: contain \u4f1a\u5728\u56fe\u7247\u4e24\u4fa7\u7559\u4e0b\u7a7a\u767d\uff0c\u800c object-fit: cover \u53c8\u4f1a\u5bfc\u81f4\u56fe\u7247\u88ab\u88c1\u526a\u3002<\/p>\n<p>\u8fd9\u91cc\u6709\u4e24\u79cd\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<p><strong>1. \u4f7f\u7528 img \u6807\u7b7e<\/strong><\/p>\n<p>`&lt;div class=&#8221;image-container&#8221;&gt;<br \/> &lt;img src=&#8221;your-image.jpg&#8221; alt=&#8221;Image&#8221;&gt;<br \/>&lt;\/div&gt;`<\/p>\n<p>`.image-container {<br \/> width: 100%;<br \/> padding-top: calc(100% \/ (16 \/ 3)); \/<em> 16:3 aspect ratio <\/em>\/<br \/> position: relative;<br \/> overflow: hidden;<br \/>}`<\/p>\n<p>`.image-container img {<br \/> position: absolute;<br \/> top: 0;<br \/> left: 0;<br \/> width: 100%;<br \/> height: 100%;<br \/> object-fit: cover; \/<em> Ensures the image covers the container <\/em>\/<br \/>}`<\/p>\n<p><strong>2. \u4f7f\u7528\u80cc\u666f\u56fe<\/strong><\/p>\n<p>&lt;div class=&#8221;image-container&#8221;&gt;&lt;\/div&gt;<\/p>\n<p>`.image-container {<br \/> width: 100%;<br \/> padding-top: calc(100% \/ (16 \/ 3)); \/<em> 16:3 aspect ratio <\/em>\/<br \/> background-image: url(&#8216;your-image.jpg&#8217;);<br \/> background-size: cover; \/<em> Ensures the image covers the container <\/em>\/<br \/> background-position: center; \/<em> Centers the image <\/em>\/<br \/> background-repeat: no-repeat; \/<em> Prevents the image from repeating <\/em>\/<br \/>}`<\/p>\n<p>\u901a\u8fc7\u8fd9\u4e24\u79cd\u65b9\u6cd5\u7684\u8fd0\u7528\uff0c\u4f60\u53ef\u4ee5\u786e\u4fdd\u56fe\u7247\u5728\u4e0d\u53d8\u5f62\u7684\u60c5\u51b5\u4e0b\uff0c\u4ee5\u5b8c\u6574\u7684\u6bd4\u4f8b\u663e\u793a\u5728\u5bb9\u5668\u4e2d\uff0c\u4ece\u800c\u8fbe\u5230\u6ee1\u5c4f\u7684\u6548\u679c\u3002<\/p>\n<p>\u7406\u8bba\u8981\u638c\u63e1\uff0c\u5b9e\u64cd\u4e0d\u80fd\u843d\uff01\u4ee5\u4e0a\u5173\u4e8e\u300a\u5982\u4f55\u8ba9\u56fe\u7247\u7b49\u6bd4\u4f8b\u5b8c\u6574\u663e\u793a\uff0c\u65e2\u4e0d\u88c1\u526a\u4e5f\u4e0d\u7559\u767d\uff1f\u300b\u7684\u8be6\u7ec6\u4ecb\u7ecd\uff0c\u5927\u5bb6\u90fd\u638c\u63e1\u4e86\u5427\uff01\u5982\u679c\u60f3\u8981\u7ee7\u7eed\u63d0\u5347\u81ea\u5df1\u7684\u80fd\u529b\uff0c\u90a3\u4e48\u5c31\u6765\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\u5427\uff01<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   \u5982\u4f55\u4ece\u7ed9\u5b9a\u6570\u5b57\u5217\u8868\u4e2d\u9009\u62e98\u4e2a\u6570\u5b57\u4f7f\u5176\u603b\u548c\u7b49\u4e8e931050\uff1f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u8ba9\u56fe\u7247\u7b49\u6bd4\u4f8b\u5b8c\u6574\u663e\u793a\uff0c\u65e2\u4e0d\u88c1\u526a\u4e5f\u4e0d\u7559\u767d\uff1f \u7c73\u4e91\u4eca\u5929\u5c06\u7ed9\u5927\u5bb6\u5e26\u6765\u300a\u5982\u4f55\u8ba9\u56fe\u7247\u7b49\u6bd4\u4f8b\u5b8c\u6574\u663e\u793a\uff0c\u65e2\u4e0d\u88c1\u526a\u4e5f\u4e0d\u7559\u767d\uff1f\u300b\uff0c\u611f\u5174\u8da3\u7684\u670b\u53cb\u8bf7\u7ee7\u7eed\u770b\u4e0b\u53bb\u5427\uff01\u4ee5\u4e0b\u5185\u5bb9\u5c06\u4f1a\u6d89\u53ca\u5230\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u662f\u6b63\u5728\u5b66\u4e60\u6587\u7ae0\u6216\u8005\u5df2\u7ecf\u662f\u5927\u4f6c\u7ea7\u522b\u4e86\uff0c\u90fd\u975e\u5e38\u6b22\u8fce\u4e5f\u5e0c\u671b\u5927\u5bb6\u90fd\u80fd\u7ed9\u6211\u5efa\u8bae\u8bc4\u8bba\u54c8~\u5e0c\u671b\u80fd\u5e2e\u52a9\u5230\u5927\u5bb6\uff01 \u56fe\u7247\u7f29\u653e\u4e0d\u53d8\u5f62\u4e14\u5185\u5bb9\u5b8c\u6574\u663e\u793a\u4e0d\u88c1\u526a\u7684\u65b9\u6cd5 \u5982\u4f55\u8ba9\u56fe\u7247\u6309\u7167\u7b49\u6bd4\u4f8b\u5b8c\u6574\u663e\u793a\uff0c\u65e2\u4e0d\u88c1\u526a\u4e5f\u4e0d\u7559\u767d\uff1f\u8fd9\u662f\u4e2a\u5e38\u89c1\u7684\u95ee\u9898\uff0c\u5c24\u5176\u662f\u5f53\u56fe\u7247\u6bd4\u4f8b\u662f\u56fa\u5b9a\u7684\u60c5\u51b5\u4e0b\u3002 \u4f7f\u7528 object-fit: contain \u4f1a\u5728\u56fe\u7247\u4e24\u4fa7\u7559\u4e0b\u7a7a\u767d\uff0c\u800c object-fit: cover \u53c8\u4f1a\u5bfc\u81f4\u56fe\u7247\u88ab\u88c1\u526a\u3002 \u8fd9\u91cc\u6709\u4e24\u79cd\u89e3\u51b3\u65b9\u6cd5\uff1a 1. \u4f7f\u7528 img \u6807\u7b7e `&lt;div class=&#8221;image-container&#8221;&gt; &lt;img src=&#8221;your-image.jpg&#8221; alt=&#8221;Image&#8221;&gt;&lt;\/div&gt;` `.image-container { width: 100%; padding-top: calc(100% \/ (16 \/ 3)); \/ 16:3 aspect ratio \/ position: relative; overflow: hidden;}` `.image-container img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; [&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-52933","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52933","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=52933"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52933\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=52933"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=52933"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=52933"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}