js style动态设置table高度
作者:whsnow 时间:2024-02-23 23:23:05
直接在table标签中设置下不就行了吗?这是静态的,如果要动态设置你会吗?
function com_onresize(){
var contentsHeight = document.body.clientHeight;
var buttonsHeight = document.getElementById( "buttons" ).offsetHeight;
var head1Height = document.getElementById( "head1" ).offsetHeight;
var head2Height = document.getElementById( "head2" ).offsetHeight;
var t1 = document.getElementById( "TableContainer1" ).style.height;
var t2 = document.getElementById( "TableContainer2" ).style.height;
//alert(document.getElementById( "TableContainer1" ).style.height);
var h = contentsHeight - buttonsHeight - head1Height - head2Height - 13;
if(h < 110){
return;
}
document.getElementById( "TableContainer1" ).style.height = h/2 + 'px';
document.getElementById( "TableContainer2" ).style.height = h/2 + 'px';
}
function com_sbs_pagesize(){
var screenHeight = window.screen.height;
var availHeight = window.screen.availHeight;
//alert(document.getElementById( "TableContainer1" ).children[0].rows.length);
var index = document.getElementById( "TableContainer1" ).children[0].rows.length
var buttonsHeight = document.getElementById( "buttons" ).offsetHeight;
var head1Height = document.getElementById( "head1" ).offsetHeight;
var head2Height = document.getElementById( "head2" ).offsetHeight;
var mainH = buttonsHeight + head1Height +head2Height + 13;
//20:scroll 35:title 25:tr
while ((availHeight-mainH) < (20 + 35 + 25*index)*2)
{
index = index - 1;
}
var tableHeight = 20 + 35 + 25*index;
document.getElementById( "TableContainer1" ).style.height = tableHeight + 'px';
document.getElementById( "TableContainer2" ).style.height = tableHeight + 'px';
window.resizeTo(document.body.offsetWidth,mainH + tableHeight*2);
}
标签:table,高度
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python编解码问题及文本文件处理方法详解
2021-04-13 07:52:06
![](https://img.aspxhome.com/file/2023/9/72999_0s.png)
深入分析C#连接Oracle数据库的连接字符串详解
2024-01-20 23:46:29
从对象列表中获取一个对象的方法,依据关键字和值
2024-05-22 10:40:02
Golang 锁原理的简单实现
2024-04-28 09:18:03
![](https://img.aspxhome.com/file/2023/2/134002_0s.png)
适合Python初学者的一些编程技巧
2022-01-14 11:19:09
关于php开启错误提示的总结
2023-11-04 10:46:21
Linux下rpm方式安装mysql教程
2024-01-21 07:40:53
python自动化测试之从命令行运行测试用例with verbosity
2021-09-20 07:32:16
![](https://img.aspxhome.com/file/2023/3/78653_0s.jpg)
python pands实现execl转csv 并修改csv指定列的方法
2022-11-20 01:45:27
怎么使用pipenv管理你的python项目
2021-01-29 06:58:41
python中return如何写
2023-11-17 21:44:56
TypeScript中命名空间与模块化详情
2024-04-25 13:11:23
![](https://img.aspxhome.com/file/2023/5/135545_0s.png)
解决Jupyter NoteBook输出的图表太小看不清问题
2023-09-07 16:00:21
pandas 实现 in 和 not in 的用法及使用心得
2021-10-23 12:25:07
![](https://img.aspxhome.com/file/2023/8/120368_0s.png)
ASP生成数字相加求和的BMP图片验证码
2011-04-14 10:48:00
![](https://img.aspxhome.com/file/UploadPic/20112/5/201125111945909s.jpg)
Go语言连接Oracle数据库的方法
2024-01-14 04:15:33
![](https://img.aspxhome.com/file/2023/8/123608_0s.png)
解决Pytorch半精度浮点型网络训练的问题
2021-10-13 17:56:45
Python 队列Queue和PriorityQueue解析
2023-07-15 20:31:11
![](https://img.aspxhome.com/file/2023/8/87938_0s.png)
php strstr查找字符串中是否包含某些字符的查找函数
2023-11-17 01:42:23
python3实现网页版raspberry pi(树莓派)小车控制
2021-05-05 05:35:18
![](https://img.aspxhome.com/file/2023/3/101283_0s.jpg)