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