Jquery width()溢出Safari问题

Jquery width() overflow Safari issue

本文关键字:Safari 问题 溢出 width Jquery      更新时间:2023-09-26

overflow:auto将表封装在窄div下。在铬,IE,FF下,宽度超过200,这是意料之中的。但在狩猎中,这个数字是100。

Jquery width()文档没有提到这一点?https://api.jquery.com/width/

代码笔,打开控制台并滚动查看日志:http://codepen.io/anon/pen/adZxrd

如果失败,请参阅以下详细信息。


HTML:

<div class="outer">
  <table class="table table-hover table-condensed">
    <thead>
      <tr>
        <td>aaaaaaaaa</td>
        <td>bbbbbbbbbbbbbb</td>
      </tr>
    </thead>
    <tbody></tbody>
  </table>
</div>

CSS:

.outer {
    width:100px;
  overflow:auto;
}
.inner {
    width:200px;
  border:1px solid black;
}

JS:

$('.outer').scroll(function(){
    console.log($('.table').width())
});

我已经找到了解决方案,至少对我来说是这样。表上有max-width: 100%(似乎是默认值),这是一个奇怪的问题,但将其设置为none解决了它。

这个问题为我解决了:Javascript:Safari/iOS中溢出容器的元素的宽度计算

工作(更新)代码笔:http://codepen.io/anon/pen/JRjOoy?editors=1111