【问题标题】:Jquery width() overflow Safari issueJquery width() 溢出 Safari 问题
【发布时间】:2016-09-02 15:34:53
【问题描述】:

使用overflow:auto 将表格包裹在一个狭窄的 div 下。在chrome、IE、FF下,宽度超过200是预期的。但在 Safari 中,with 是 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())
});

【问题讨论】:

  • 你找到解决办法了吗?

标签: javascript jquery css safari width


【解决方案1】:

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

这个问题为我解决了:Javascript: Calculation of width in Safari/iOS for elements overflowing their containers

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

【讨论】:

    猜你喜欢
    • 2011-04-30
    • 2020-10-12
    • 1970-01-01
    • 1970-01-01
    • 2013-05-09
    • 1970-01-01
    • 2019-10-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多