」工欲善其事,必先利其器。「—孔子《論語.錄靈公》
首頁 > 程式設計 > 對象擬合:IE和Edge中的封面失敗,如何修復?

對象擬合:IE和Edge中的封面失敗,如何修復?

發佈於2025-04-26
瀏覽:770

Object-Fit: Cover Fails in IE and Edge, How to Fix?

To resolve this issue, we employ a clever CSS solution that solves the problem:

position: absolute;

top: 50%;

left: 50%;

transform: translate(-50%, -50%);

高度:auto;

寬度:100%; //對於水平塊
,使用絕對定位將圖像定位在中心,以object-fit:cover in IE和Edge消除了問題。 The image will now scale proportionally, maintaining the desired effect without distortion.

To illustrate the solution's effectiveness, consider the following demonstration:


Image Resizing Demonstration

This approach ensures consistent image behavior across all browsers, effectively addressing the object-fit: cover issue in IE and Edge.

最新教學 更多>

免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。

Copyright© 2022 湘ICP备2022001581号-3