【问题标题】:Why is IE7 & IE8 says that it 'hasLayout', when it doesn't?为什么 IE7 和 IE8 说它“hasLayout”,而实际上却没有?
【发布时间】:2013-09-06 22:11:17
【问题描述】:

HTML:

  <div class="table" >
      <div class="row" >
        <span>Tb with DIV</span> <span>col2</span> <span>col3</span>
      </div>
        <div class="row" >
        <span>col1</span> <span>col2 test</span> <span>col3</span>
      </div>
        <div class="row" > <span>col1</span> <span>col2</span> <span>col3 test</span>
      </div>
    </div>

    <table>
      <tr id="testRow">
        <td>Tb with <'table'></td> <td>col2</td> <td>col3</td>
      </tr>
      <tr >
        <td>col1</td> <td>col2 test</td> <td>col3</td>
      </tr>
      <tr >
        <td>col1</td> <td>col2</td> <td>col3 test</td>
      </tr>
    </table>

CSS:

.table, table {
    display:table; 
        /*
        width:200px; 
        height:100px;
        zoom:1;
        */
        }
.row  { display:table-row; }
.row, tr {
        width:200px !important;
        min-height:1px !important;
        zoom:1;
        white-space:nowrap;

   -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";
    filter: alpha(opacity=20);
    -moz-opacity:0.2;
    -khtml-opacity: 0.2;
    opacity: 0.2;
}
.row span, td {display:table-cell;padding: 5px;}

Javascript

$(function () { 
    console.log (document.getElementById('testRow2').currentStyle.hasLayout);
    //$('.row, tr').fadeTo('fast',0.2);
});

jsbin jsfiddle

因为不透明度不起作用,我应该在控制台中得到“假”(对于 IE7 和 8),但结果是“真”

元素是否真的“hasLayout”但不透明度由于其他原因不起作用?

虽然我对此表示怀疑,因为即使是 jQuery 也无法设置不透明度。

【问题讨论】:

标签: javascript css internet-explorer html-table haslayout


【解决方案1】:

看起来所有“table”元素默认都有hasLayout===trueopacity for tr 不起作用,因为您需要为 td 定义 opacity

【讨论】:

  • 这是真的,他们默认有'hasLayout'。这就是为什么更有趣的是为什么不起作用。 (事实上​​,我可以在 'td' 上设置不透明度,因为在除 IE
  • 好吧,IE 有完全不同的表模型,为什么它会用opacity 例外:) 顺便说一句。 opacityhasLayout 之间的假定联系是什么?
  • 你不能在没有 'hasLayout' 的元素上使用不透明度(这对 jQuery fadeTo() 也有效)
猜你喜欢
  • 2023-02-20
  • 2022-07-27
  • 2022-11-27
  • 1970-01-01
  • 2011-06-07
  • 1970-01-01
  • 1970-01-01
  • 2014-06-21
  • 2011-07-03
相关资源
最近更新 更多