jQuery控制表格垂直滚动条

表格table水平自适应,可以设置宽度100%
表格table垂直自适应,需要设置表格的高度,根据高度,表格的垂直滚动条会自动的显示和隐藏
垂直滚动条,需要设置指定的高度,当table的高度超过这个高度时,就会出现垂直滚动条
页面的元素都是分块的,tab、search、title、button、table等模块,页面和页面上的元素也是不一样的,需要jQuery获取高度

// 页面初始化
$(function () {
    var webHeight = window.innerHeight;
    var tabHeight = $('.tabStyle').innerHeight();
    var searchHeight = $('.searchStyle').innerHeight();
    var titleHeight = $('.toolTitleStyle').innerHeight();
    var toolHeight = $('.toolStyle').innerHeight();
    var pageHeight = $('.pagefooterStyle').innerHeight();
    if (tabHeight == null) {
        tabHeight = 0;
    }
    if (searchHeight == null) {
        searchHeight = 0;
    }
    if (titleHeight == null) {
        titleHeight = 0;
    }
    if (toolHeight == null) {
        toolHeight = 0;
    }
    if (pageHeight == null) {
        pageHeight = 0;
    }
    var height = webHeight - tabHeight - searchHeight - titleHeight - toolHeight - pageHeight - 8;
    var table = $('.listTableStyle');
    if (table != null) {
        $('.listTableStyle').css("height", height);
    }
});

// 浏览器改变大小
$(window).resize(function () {
    var webHeight = window.innerHeight;
    var tabHeight = $('.tabStyle').innerHeight();
    var searchHeight = $('.searchStyle').innerHeight();
    var titleHeight = $('.toolTitleStyle').innerHeight();
    var toolHeight = $('.toolStyle').innerHeight();
    var pageHeight = $('.pagefooterStyle').innerHeight();
    if (tabHeight == null) {
        tabHeight = 0;
    }
    if (searchHeight == null) {
        searchHeight = 0;
    }
    if (titleHeight == null) {
        titleHeight = 0;
    }
    if (toolHeight == null) {
        toolHeight = 0;
    }
    if (pageHeight == null) {
        pageHeight = 0;
    }
    var height = webHeight - tabHeight - searchHeight - titleHeight - toolHeight - pageHeight - 8;
    var table = $('.listTableStyle');
    if (table != null) {
        $('.listTableStyle').css("height", height);
    }
});
相关文章
相关标签/搜索