相关疑难解决方法(0)

在Internet Explorer中设置最大宽度

我需要的是在Internet Explorer中将图像宽度的限制设置为100%,就像其他浏览器一样max-width.也就是说,如果图像的宽度大于包含区域的宽度,则它会向下缩小以适应包含区域的宽度,但如果它更小,则其大小不会改变.同样,如果图像位于表格单元格(td)中并且它大于单元格,我希望它缩放到单元格的大小,而不是扩展它.

虽然还有其他问题和答案似乎与此有关,但我无法让它们中的任何一个起作用.例如,通常建议此解决方案在Internet Explorer中模拟最大宽度:

http://www.svendtofte.com/code/max_width_in_ie/

本质上使用这个:

width:expression( 
    document.body.clientWidth > (500/12) * 
    parseInt(document.body.currentStyle.fontSize)?
        "30em":
        "auto" );
}
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试它时,我根本得不到预期的结果.在某些情况下,当我检查Firebug或类似的东西时,我得到宽度值-1并且根本没有显示图像.

我也不知道这个解决方案是如何运作的.

编辑:

根据要求,这里有一些示例代码:

<table cellpadding="4" cellspacing="0"
    summary="" id="Push12Matt__simpletable_rph_vch_32" border="0" class="simpletable">
    <tr class="strow">
     <td valign="top" class="stentry" width="50%">
      <div class="fig fignone" id="Push12Matt__fig_6a268fd9-2a26-474f-83f5-528ffbab70d3"><a
        name="Push12Matt__fig_6a268fd9-2a26-474f-83f5-528ffbab70d3"><!-- --></a><p class="figcap"
        >Bild 1. Uponor Push 12</p>
       <a name="Push12Matt__image_4dd4d9ef-f95c-41f1-b423-7ddd3a2b0c06"><!-- --></a><img
        class="image" id="Push12Matt__image_4dd4d9ef-f95c-41f1-b423-7ddd3a2b0c06"
        src="/handbok/images/Push12/Push12_byggmatt.jpg" />
      </div>
     </td>

     <td valign="top" class="stentry" width="50%">
      <div class="fig fignone" id="Push12Matt__fig_689a2b08-ffbb-4f92-9a27-010e99665959"><a
        name="Push12Matt__fig_689a2b08-ffbb-4f92-9a27-010e99665959"><!-- --></a><p class="figcap"
        >Bild 2. Uponor ElPush 12</p>
       <a name="Push12Matt__image_f6d7c2fa-8ab3-4e46-b79c-e7881dff03e9"><!-- --></a><img
        class="image" id="Push12Matt__image_f6d7c2fa-8ab3-4e46-b79c-e7881dff03e9"
        src="/handbok/images/Push12/Push12Electronic_byggmatt.jpg" …
Run Code Online (Sandbox Code Playgroud)

css internet-explorer

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

css ×1

internet-explorer ×1