【问题标题】:Maintain image ratio in IE在 IE 中保持图像比例
【发布时间】:2013-06-04 18:57:32
【问题描述】:

我正在尝试在 IE 中保持图像比例,但我没有运气...我拿了一个画廊插件并将其修改为我的需要,这是目前唯一剩下的问题。

谁能建议一个简单的解决方案? jQuery 或 CSS...

Here is where it has to work (second image in IE)

【问题讨论】:

  • 什么版本的 IE?
  • IE10和IE9,老的没关系
  • 我提供的解决方案应该适用于所有 IE 版本。 :)

标签: jquery css image internet-explorer


【解决方案1】:

通常,(在所有个浏览器中),为图像的一个尺寸设置一个值会导致另一个尺寸适当地缩放:

<img src="oo-la-la.png" width="50px" />
<img src="oo-la-la.png" style="height:50px;" />

你也可以使用百分比:

<img src="oo-la-la.png" style="width:100%;"/>

这些工作是因为浏览器默认将图像尺寸设置为auto。有时(如本例)您需要自己强制执行此行为:

.slideshow_image {
    /* Set whatever width or height you like */
    width: 100%;

    /* Enforce auto scaling for the other dimension */
    height: auto !important; 
}

【讨论】:

    猜你喜欢
    • 2017-05-20
    • 2023-03-14
    • 2010-12-31
    • 1970-01-01
    • 1970-01-01
    • 2015-02-17
    • 2014-02-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多