【发布时间】:2015-02-03 11:12:48
【问题描述】:
我的这个页面包含一个包含 10-12 个值的表格,每个表格单元格 (td) 都有一些 padding(10px)。获取正文宽度的最佳方法是什么,包括包含padded cells.的表格宽度
我尝试过使用
window.innerWidth(true)
element.containerWidth
在 JS 中,但它返回我身体的宽度,没有内部元素的填充。
和宽度:CSS 中的 100%。没有任何效果。
编辑: 即使在使用 outerWidth(true) 之后,它也只包含可视区域,而不是总区域或可滚动宽度。可滚动宽度怎么取?
我的代码是
<script>
window.onresize = displayWindowSize;
window.onload = displayWindowSize;
function displayWindowSize() {
Width = $('body').outerWidth(true);
Height = $('body').outerWidth(true);
$('#header-bar').css('width',Width);
$('#exec2').css('height',Height);
$('#exec2').css('width', Width);
$('#exec1').css('width', Width);
$('#exec1').css('height',Height);
};
</script>
【问题讨论】:
标签: javascript jquery html css