【问题标题】:Unable to resize img Internet Explorer无法调整 img Internet Explorer 的大小
【发布时间】:2013-12-28 10:59:42
【问题描述】:

我经营一个网站,我最近发表了一篇文章,在 Chrome 和 FireFox 上完全没问题,但在 Internet Explorer 上有些问题。

被指控的页面是this one

为了简单起见,我在这里分享一部分代码:

<figure class="appFigureElement" id="airDroidFigure">
    <a href="https://play.google.com/store/apps/details?id=com.sand.airdroid&hl=en"><img id="airDroidPicture" class="imageApps" alt="airDroid" src="path to image"/></a>
    <figcaption id="airDroidCaption">
        <p> blablabla </p>
    </figcaption>
</figure>


.imageApps
{
    width: 75px;
    height: 75px;
    float: left;
    padding-right: 10px;
}


.appFigureElement
{
    padding-bottom: 25px;   
}


function setFigureHeight(figure, picture, caption)
{
    var figureEl = jQuery("#" + figure);
    var pictureEl = jQuery("#" + picture);
    var captionEl = jQuery("#" + caption);

    if(pictureEl.outerHeight(true) > captionEl.outerHeight(true))
        figureEl.height(pictureEl.outerHeight(true));
    else
    {
        figureEl.height(captionEl.outerHeight(true));
        var mrgBott = captionEl.outerHeight(true) - pictureEl.outerHeight(true) + 15;
        pictureEl.css("margin-bottom", mrgBott+"px");
    }



}

基本上在 onLoad 事件中,我运行 js 函数,该函数根据 CSS 格式化每个“平铺”(图形元素)。

问题在于,在 IE 中,CSS 就像丢失了一样,从某种意义上说,图片非常巨大,无论我如何尝试调整它们的大小(html 内的 css,图形外的 img 等等),我总是得到巨大的图像,而在 Chrome 和 FF 中一切都很好。

你有什么建议吗?

Ps网站是用WordPress开发的

【问题讨论】:

    标签: css html internet-explorer height width


    【解决方案1】:

    在您的 style.css 中,存在一个规则:

    .ie #content img, .ie #comments img, .ie .sidebar img {
        height: auto;
    }
    

    那是你的罪魁祸首。

    为了进一步解释,这条规则写在之后你的规则使它覆盖你正在调整图像大小的 .imageApps 类。由于它仅适用于 IE,这就是为什么您在其他浏览器中没有看到此问题的原因。

    【讨论】:

    • 我应该删除该规则吗?可能它是由 WordPress 编写的,如果我删除它,我会破坏一些东西......
    • 只需确保您的 imageApps 规则在 CSS 中位于它之后。或者您可以使用 !important ,但这通常是不受欢迎的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-16
    • 2016-03-10
    • 1970-01-01
    • 2012-08-09
    • 2013-05-16
    相关资源
    最近更新 更多