js style動態(tài)設(shè)置table高度
更新時間:2014年10月21日 17:20:16 投稿:whsnow
設(shè)置table高度想必大家都會,直接在table標(biāo)簽中設(shè)置下不就行了嗎?這是靜態(tài)的,如果要動態(tài)設(shè)置你會嗎?下面的實(shí)例將教會大家
直接在table標(biāo)簽中設(shè)置下不就行了嗎?這是靜態(tài)的,如果要動態(tài)設(shè)置你會嗎?
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); }
相關(guān)文章
細(xì)說webpack源碼之compile流程-rules參數(shù)處理技巧(1)
webpack作為一種流行的打包工具被廣泛應(yīng)用在web項目的前端工程化構(gòu)建中。下面通過本文給大家介紹webpack源碼之compile流程-rules參數(shù)處理技巧,感興趣的朋友一起看看吧2017-12-12JS實(shí)現(xiàn)的四級密碼強(qiáng)度檢測功能示例
這篇文章主要介紹了JS實(shí)現(xiàn)的四級密碼強(qiáng)度檢測功能,具有實(shí)時檢測輸入密碼強(qiáng)度的功能,涉及javascript針對字符串的正則判定相關(guān)操作技巧,需要的朋友可以參考下2017-05-05

用js統(tǒng)計用戶下載網(wǎng)頁所需時間的腳本
下面的方法是個不錯的思路,建議對于js感興趣的朋友,推薦看
2008-10-10 
JS跳出循環(huán)的方法區(qū)別對比分析(break,continue,return)
面向?qū)ο缶幊陶Z法中我們會碰到break ,continue, return這三個常用的關(guān)鍵字,那么關(guān)于這三個關(guān)鍵字的使用具體的操作是什么呢?接下來通過本文給大家講解JS跳出循環(huán)的方法區(qū)別對比分析(break,continue,return),感興趣的朋友一起看看吧
2023-02-02