position: absolute;top: 50%;
left: 50%;transform: translate(-50%, -50%);
高度:auto;寬度:100%; //對於水平塊
This approach ensures consistent image behavior across all browsers, effectively addressing the object-fit: cover issue in IE and Edge.
,使用絕對定位將圖像定位在中心,以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
免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。
Copyright© 2022 湘ICP备2022001581号-3