gpt4 book ai didi

javascript - Jquery width() 溢出 Safari 问题

转载 作者:太空宇宙 更新时间:2023-11-04 02:42:36 26 4
gpt4 key购买 nike

使用 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())
});

最佳答案

我找到了解决方案,至少对我来说是这样。表格上有 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

关于javascript - Jquery width() 溢出 Safari 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34431416/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com