【问题标题】:Object Fit not working on Internet Explorer对象适合在 Internet Explorer 上不起作用
【发布时间】:2020-05-12 16:22:28
【问题描述】:

是否可以添加适用于 Internet Explorer 的对象拟合属性,因为 ie 没有引入对象拟合。那么我该怎么办呢?任何可能的解决方案?

【问题讨论】:

标签: css internet-explorer


【解决方案1】:

Internet Explorer 浏览器不支持object-fit 属性。我建议你参考 Phe0nix/object-fit-ie polyfill。

object-fit polyfill 仅适用于 IE 中的图像。其他所有浏览器(Chrome、Safari、Firefox、Opera、Edge)都支持“object-fit”属性。它有助于将图像放入容器中。

语法:

objectFitIE.ieImg('image-wrapper-class-name', 'object-position x', 'object-position y', 'object-fit');
  1. image-wrapper-class-name - 将您的包装类名称放在这里。请参阅下面的示例 -

它将以类包装名称为目标。确保在包装器中只有一张图片。

  1. 对象位置 x 和对象位置 y - 放置 x 和 y 轴的值。就像 css 中的对象位置一样。

  2. object-fit - 像在 css 中一样放置 object-fit 值。

用法:

  1. 创建要应用对象匹配属性的图像的包装器。

  2. 在您的代码库中包含 object-fit-ie.js 文件。

  3. 在正文结束前调用它

objectFitIE.ieImg('image-wrapper-class-name', 'object-position x', 'object-position y', 'object-fit');

  1. 在 IE 浏览器中查看。

Demo link

参考:

object-fit-ie

【讨论】:

    猜你喜欢
    • 2017-06-07
    • 2012-07-31
    • 2020-02-23
    • 2013-03-23
    • 1970-01-01
    • 2014-10-29
    • 2013-12-29
    • 2017-08-06
    • 1970-01-01
    相关资源
    最近更新 更多